I have a this form.
<%= form_for @snitch, html: { class: "form-actions", method: 'delete' } do |form| %>
<span class="button-text"><%= link_to 'NO WAY!', home_base_url_or_default(root_path), rel: "modal:close" %></span>
<input type="submit" class="button button--modal delete-snitch" data-snitch-id="<% @snitch.token %>" value="Yes, delete it.">
<% end %>
As you can see on the 3rd line there is an input type. I have this attribute on it data-snitch-id
I have it set to the snitch token. I'm just wondering if that is correct because its coming back as undefined...
Here is how I know.
I'm using it for a Ajax call
$(document).on('click','.delete-snitch', function(e) {
e.preventDefault();
var snitchID = $(this).attr('data-snitch-id');
$.ajax({
type: 'DELETE',
url: '/snitches/' + snitchID,
datatype: 'json'
success: function(){
$('#tr-for-snitch-' + snitchID).fadeOut
}
});
});
But it's not working because the data-snitch-id
comes back as undefined.
您必须使用<%= @snitch.token %>
而不是<% @snitch.token %>
来输出该值。
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.