Prevent submit event of remote => ‘true’ Rails form which open in Modal

We can not directly prevent the form which submit using remote => true

This example show how to prevent submit event of ajax  form which open in modal

$(".modal-form").live("ajax:before",function(evt,data,status,xhr){
   var checked = $(".project-modal-form input:checked").length > 0
   if (!checked){
     $("#warning_notification-project-modal").text("Warning.").slideDown(70         0).delay(7000).slideUp(700);
     $('#warning_notification-project-modal').removeClass('hide')
     return false; 
   }else{
      return true;
     }
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s