The following code works in jsfiddle to hide a div but not in my Rails app. In my rails app, a remote javascript call is made to show the div that I intend to hide when a Cancel button is clicked:
<form id="new_thing" class="new_thing" method="post" data-remote="true">
<input></input>
<input></input>
<input class="btn btn-primary" type="submit" value="Submit" name="commit" id="fuck">
<button id="thing_cancel" class="btn btn-primary" type="button" name="button">Cancel</button>
</form>
The JS:
$("#thing_cancel").click(function () {
$('#new_thing').hide();
});
In my app, I try:
<%= button_tag "Cancel", :class => "btn btn-primary", :type => "button", :id => "position_cancel" %>
where clicking the button does nothing. Adding :remote => true and using link_to has yielded the same result.
With, in my assets/javascripts/thing.js:
$('#thing_cancel').click(function(){
event.preventDefault();
$('#new_thing').hide();
$('#new_thing_link').show();
});
I've found several somewhat related questions but nothing has worked thus far. Is there something I'm missing with the whole turbolinks thing? I have:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require jquery.turbolinks