Hi Justin,
Thanks for your reply, after my posts above I found a solution to my
second problem where the Ajax function doesn't fire the 2nd
consequtive time you call it.
Just as you had in your post, I needed to have another 'Observe' in
the returned HTML from the handler function.
>Event.observe(document, 'dom:loaded', prepare);
Although this works find, I would have liked to find a way where my
markup is clean of any javascript and the default Observer worked from
the linked .js file (as it does on the first ajax request).
Thanks again
On Jan 23, 5:00 pm, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> Let's start with some basic code that you can try out and then
> follow-up with questions you may have.
>
> First, some JavaScript:
>
> function prepare(){
> var form = $('my-form');
> form.observe('submit', handle);
>
> }
>
> function handle(event){
> event.stop();
> var form = $('my-form');
> new Ajax.Request('/my-page', { parameters:Form.serialize(form),
> onComplete: callback } );
>
> }
>
> function callback(response){
> alert(response.transport.responseText);
>
> }
>
> //----------------
>
> And the HTML
>
> <form id="my-form" action="/my-page">
> <input type="submit" value="Submit this silly form!" />
> </form>
> <script type="text/javascript">
> Event.observe(document, 'dom:loaded', prepare);
> </script>
>
> I haven't tested any of this code, but I think it should work. I
> recommend getting yourself with the documentation on the Prototype
> API:http://prototypejs.org/api
>
> Have a great night.
>
> -justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---