Wordpress+require.js jQuery(...).isotope is not a function -
i'm using require.js within wordpress, , i've accomplished load vendor , custom scripts page, except 1 file... if try load 'isotope.pkgd.min' through require js console shows error:
jquery(...).isotope not function
the error comes file i'm loading in require.js, called 'jquery.theme', executes code:
jquery('.portfolio-isotope').isotope( 'layout' ); jquery('.ajax-isotope').isotope( 'layout' );
first of thought problem jquery duplicity(because plugins use own jquery version instead of wp default version), solved it, using in require.js config jquery default in wp, code:
if (typeof jquery === 'function') { define('jquery', function () { return jquery; }); }
but that, didn't solve anything. i've seen if leave wp isotope default call, , load 1 require.js,the default 1 inside body tag, , require 1 inside head. maybe putting require.js 1 inside body tag solve problem? no idea on how that.
my require.js config file:
requirejs.config({ baseurl: './wp-content/themes/alterna-child/assets/js/', paths: { jquery_ui: 'vendor/jquery-ui/jquery-ui', jquery_ui_touch_punch: 'vendor/jquery-ui/jquery.ui.touch-punch.min', jquery_ui_slider_pips: 'vendor/jquery-ui/jquery-ui-slider-pips', bootstrap: 'vendor/bootstrap/bootstrap.min', isotope: 'vendor/isotope/isotope.pkgd.min', fancybox_mousewheel: 'vendor/fancybox/jquery.mousewheel-3.0.6.pack', fancybox_js: 'vendor/fancybox/jquery.fancybox.pack', fancybox_helpers_js: 'vendor/fancybox/helpers/jquery.fancybox-thumbs', flexslider_js: 'vendor/flexslider/jquery.flexslider-min', csstransforms3d: 'csstransforms3d', select: 'vendor/bootstrap-select/bootstrap-select' }, shim: { 'bootstrap': { deps: ['jquery'] }, 'isotope': { deps: ['jquery'] }, 'fancybox_mousewheel': { deps: ['jquery'] }, 'fancybox_js': { deps: ['jquery'] }, 'fancybox_helpers_js': { deps: ['jquery'] }, 'flexslider_js': { deps: ['jquery'] }, 'csstransforms3d': { deps: ['jquery'] }, 'jquery_ui': { deps: ['jquery'] }, 'jquery_uitouch_punch': { deps: ['jquery','jquery_ui'] }, 'jquery_ui_slider_pips': { deps: ['jquery','jquery_ui'] }, 'select': { deps: ['jquery'] } } }); if (typeof jquery === 'function') { define('jquery', function () { return jquery; }); } requirejs(['jquery','bootstrap','isotope','fancybox_mousewheel','fancybox_js', 'fancybox_helpers_js','jquery_ui','jquery_ui_touch_punch','jquery_ui_slider_pips','select','jquery.theme'], function ($) { console.log("it works"); });
p.s: require js file loaded in wp_footer through function in 'functions.php' child theme.
Comments
Post a Comment