0

I am using ruby on rails, and i discover wookmark jquery plugin and would like to use it. http://www.wookmark.com/jquery-plugin

I have installed the gemfile

gem "jquery-wookmark-rails", "~> 0.0.1"

and i have added to javascripts/application.js

//= require jquery.wookmark

But now I don't know how to apply it to my pictures on my view!

<span class="photo">
    <% if feed_item.image? %>

    <!-- Button trigger modal -->
    <a data-toggle="modal" data-target="#myModal<%= feed_item.id %>" data-refresh="true">
        <%= image_tag feed_item.image.url,:size => "180x180" %>
    </a>

    <!-- Modal -->
      ...

    <% end %>
</span>

Thanks !

4

1 回答 1

0

Follow Rails Best practices with regards to javascript until you know what you're doing. So you would not write the javascript inline with your html code in your .html.erb files.

You want to write you javascript code in the app/assets/javascript directory. Usually Rails will put a file in this folder with the same name corresponding to the rails controller associated with the views, though this is just a way to organize your javascript, the asset pipeline will compress and concat all your javascript for performance reason. In the Rails world we call this unobtrusive javascript.

Now, as to your question, consult the woomark documentation, reading documentation is your friend and you will learn more and won't have to post questions on SO.

So in your .js.coffee file or .js file in app/assets/javascript (NOT THE APPLICATION.JS FILE, THIS IS A MANIFEST FILE) you'd write something like

$ ->
  $('#myContent).wookmark()

Thats it.

于 2013-12-09T14:50:29.737 回答