简体   繁体   中英

Trouble installing jquery plugin in rails.

I looked through some related questions suggesting how to maneuver the asset pipeline, but still am unable to get it to work.

index.html.erb:

<%= javascript_include_tag "playlist" %>

<div class="demo">
  <div class="demoPlate plate" style="margin: 0 auto;">

  </div>
</div>

application.js:

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require plate.js
//= require bootstrap
//= require bindWithDelay
//= require jquery.datetimepicker
//= require_tree .

$(document).ready(function(){
  $("#event_when").datetimepicker({
    format:'Y/m/d H:i'
  });
  $("#user_dob").datetimepicker({
    timepicker:false,
    format:'Y/m/d',
    maxDate:'0'
  });
});

playlist.js:

 $(function(){
      $('.demoPlate').plate({
        playlist: [
          {"file":"files/morgantj_-_caf_connection_1.mp3"}
        ]
      });
    });

The files that the plugin need to be compiled are: jquery-ui, jquery, plate.js, and they have playlist.js in the body.

I have tried all ends of the asset pipeline, but cant figure out what im missing.

The instructions they gave for installing are (Screenshots): Part 1 Part 2

Any help is greatly appreciated!

If you put the following inside application.js

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require plate.js
//= require bootstrap
//= require bindWithDelay
//= require jquery.datetimepicker

You should have all of these files inside the directory of app/assest/javascripts

I will automatically loaded inside one file "application.js" , no need to declare or include inside <head></head> tag, unless you don't include the application.js file in layout.

you can also require playlist.js after setting up jquery plugins/dependencies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM