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 !

2ueenO
  • 164
  • 1
  • 1
  • 10
  • You might want to check the documentation: https://github.com/GBKS/Wookmark-jQuery – fmendez Dec 09 '13 at 14:17
  • You haven't actually called any javascript yet. You need to call their .wookmark() function. – kddeisz Dec 09 '13 at 14:26
  • Yes but i'm a beginner with that, and i don't know how to call this javascript function. This is my question! Am i supposed to do something like : `` ? – 2ueenO Dec 09 '13 at 14:28

1 Answers1

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.

TheIrishGuy
  • 2,531
  • 19
  • 23