When using the FormHelper.FormTag(...) in Monorail you can simply do something like this:
<?brail output Form.FormTag({@action:"edit"}) ?>
This will render something like this:
<form id="form1" action="edit.rails" [other attributes]>
Usually I am diligent about naming/id-ing my html elements, especially those which are obvious containers such as divs, fieldsets, forms. However, I had placed a <form/> tag inside an view which would be slurped into my page via MonoRails's Javascript generation.
When I performed a submit the first time inside my form, the action was called and things were great. The problem was when I tried to perform another action inside the same area. Instead of firing the form via ajax I would actually render the raw javascript which the JS generator responded with.
At first, I thought since my form was getting added dynamically to the DOM the submit event of the form wasn't getting subscribed. I am using jQuery so I looked at the livequery plugin to handle this. However something bothered me about this so I looked again at my view source. I noticed that the <form/> that was brought in had an id of 'form1' as Monorail creates and id for you when you have not specified an id explicitly. The problem, of coursse, was that I had another 'form1' on my page, resulting in duplicate ids, confusing the Form plugin and posting the data via standard request.
The simple fix was to explicitly define ids on my form elements and all is good. Good reminder to be more disciplined with my page creation.
Posted
03-24-2008 12:34 AM
by
Michael Nichols