I am using jquery-ui-rails gem. I want to implement a simple example of draggable and droppable. This is the javascript file:
$('.draggable_images').draggable();
$('#droppable1').droppable({
drop: function(event,ui){
$(this).addClass("ui-state-highlight").find("p").html("Added!");
}
});
But the contents of the droppable p tag does not change when an image is dropped. The same code worked when i tried in fiddle. I though it could be the issue with jquery-rails and the jquery-ui-rails compatibility, but the versions of jquery-rails is 3.1.2, and ui-rails is 5.0.3.
What am I doing wrong?
These are the other files:
the html file `
<% @ingredients.each do |ingredient| %>
<li class = "draggable_images">
<%= image_tag Ingredient.where(id: ingredient.ingredient_id).first.image_url%>
</li>
<% end %>
</ul>
<style>
#droppable1 { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; border-style: solid;}
</style>
<div id="droppable1">
<p>Drop here</p>
</div>
Application.js
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require turbolinks
//= require_tree .
/* Developer JS */
//= require welcome
Application.css
*= require jquery-ui
*= require_tree .
*= require_self
I have also precompiled the assets