ruby on rails 3.1 - two simple forms, why I can't submit the one I want? -


the 2 simple forms have looks this:

= simple_form_for(@class_room, :html=>{:id=>'class_room_form'}) |class_room_form| 

and

= simple_form_for(@lesson, :html => {:id=>'lesson_form'}) |lesson_form| 

now, although submitting form of id lesson_form, form id class_room_form submitted instead! idea ?

here how submit lesson_form form:

:javascript   $('#submit_lesson_button').bind('click', function() {     $("#lesson_form").trigger('submit');     }); 

here how submit other form ( 1 still submitted regardlessly )

:javascript   $('#submit_button').bind('click', function() {     $('#sidenav a:first').tab('show');     $('#class_room_form').trigger('submit');     }); 

you see, each form different ids, , targeting different ids jquery, wrong ??

notice form lesson_form contained within form class_room_form

you're not supposed have form contained form. if can change this, solve problem, , code cleaner.

if can't, try add event.preventdefault() functions, :

:javascript   $('#submit_lesson_button').bind('click', function(event) {     event.preventdefault();     $("#lesson_form").trigger('submit');   });  :javascript   $('#submit_button').bind('click', function() {     event.preventdefault();     $('#sidenav a:first').tab('show');     $('#class_room_form').trigger('submit');   }); 

i suppose #submit_lesson_button , #submit_button <input type="submit" ... >


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -