Simple Javascript Joyride plugin in rails

前端 未结 3 817
你的背包
你的背包 2021-01-23 09:30

I\'m afraid my plugin isn\'t working properly because of a misunderstanding of rails. I\'m adding zurbs joyride plugin to an index page.

I have the following in v

3条回答
  •  自闭症患者
    2021-01-23 10:21

    i have been having the same issue with joyride, i just got it working , just to complete what already said in my case

    first step : in the vendor/assets/javascripts i remove the js at the end of the file name and also in the application.js place the require file in the same order from the demo. and also require the css file

    second step : i create a partial that contain the code for the joyride place it in the folder that will contain the joyride views and render it in the layout/application.html.erb place after my footer

    3rd step: i convert the javascript in coffeescript with js2coffee.org exemple from the demo

    $(window).load(function() {
        $('#joyRideTipContent').joyride({
          autoStart : true,
          postStepCallback : function (index, tip) {
          if (index == 2) {
            $(this).joyride('set_li', false, 1);
          }
        },
        modal:true,
        expose: true
        });
      });
    

    to coffeescript:

     $(window).load ->
      $("#joyRideTipContent").joyride
        autoStart: true
        postStepCallback: (index, tip) ->
          $(this).joyride "set_li", false, 1  if index is 2
    
        modal: true
        expose: true
    

    so basically this is the step that i did and it works for me .

    P.s try not to put the file in another folder inside vendor/assets/javascripts , they are going to be compiled anyway.

提交回复
热议问题