1

I have add a custom.js file under my_child theme folder web/js/custom.js

here is code

define([
  "jquery"
], 
function($) {
        "use strict";

        $('#shipping').find('.step-title').click(function(){

          //Expand or collapse this panel
          $(this).next().slideToggle('fast');

          //Hide the other panels
          $(".step-content").not($(this).next()).slideUp('fast');

        });

        console.log('My log');
});

I have create requirejs-config.js

var config = {
  deps: [
    "js/custom"
  ]
};

'My log' is print on console but jquery accordion does not works. If i copy and past custom.js function on browser console it works fine

website is in developer mode how can i debug?

  • load the js after content load then check. – Qaisar Satti Oct 25 '17 at 7:51
  • just try with define([jquery','domReady!'] but it load before all why? – Altravista Oct 25 '17 at 7:59
1

solved in this way. thanks to Lucas

define([
  'jquery','rjsResolver'
], 
function($, resolver) {
        "use strict";

        resolver( function (){
            $('#shipping').find('.step-title').click(function(){

          //Expand or collapse this panel
          $(this).next().slideToggle('fast');

          //Hide the other panels
          $(".step-content").not($(this).next()).slideUp('fast');

        });

        console.log('Accordion Eseguito');      
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.