Reputation: 15501
I have this popup that holds 2 buttons to decline and accept the problem is I'm trying to style the buttons and still also trigger a JS event to close the popup ( its a modal ajax popup) Problem is I have som lack of inspiration and ideas to get the below 3 elements combined together.
Some rails code:
// ACCEPT FORM
= form_tag(friend_path, :method => 'post', :remote => true) do
= hidden_field_tag :user_id, current_user.id
= submit_tag 'ACCEPT'
// DECLINE FORM
= form_tag(friend_path, :method => 'post', :remote => true) do
= hidden_field_tag :user_id, current_user.id
= submit_tag 'DECLINE'
//fbmodal.close ()
Anyone some ideas how I can have the buttons
styleable ( like with twitter bootstrap )
still send with ajax
trigger a JS event to close the popup?
Upvotes: 1
Views: 283
Reputation: 1166
Styleable buttons:
%button.btn#accept-button
%i.icon-plus
Accept
Your JS can then be something like:
$(document).ready(function() {
$('#accept-button').click(function() {
// replace this with your AJAX call
$.get('/foo.json');
// close the modal
$('#your-modal-id').modal('hide');
// and don't submit
return false;
});
});
Upvotes: 1