Hi,
"http://mooshell.net/VNE5e/"
This doesn't work for me, as the form will be submitted standard way
not with help of AJAX.
OK, I will write the whole code, so you know what exactly should be
done:
HTML:
<form id="formid" method="post" action="" class="formclass">
<input type hidden name="id" value="1">
</form>
<div><a onclick="$('formid').submit();">Submit</a><div> or ( <div><a
onclick="$('formid').fireEvent('submit');" >Submit</a></div>)
JAVASCRIPT(AJAX):
$$('form.formclass').addEvent('submit', function(e){
new Event(e).stop();
var req = new Request.HTML({
url: 'post-work.php',
data: $(formid),// formid data I get with other function
update: $('updateelement'),
}).send();
});
I don't use 'click' event for the form, because on the site there are
more forms, so I need to get data through $$('form.formclass'), not
through $('formid'). So because I don't know which form will be
submitted, the event is "submit" and I cannot use direct "click" event
of URL link. The URL link should only start "submit" of form and then
AJAX should listen to "submit" event.
On 8 zář, 23:16, Ryan Florence <[email protected]> wrote:
> So this is what you want?
>
> http://mooshell.net/VNE5e/
>
> On Sep 8, 2009, at 3:11 PM, Aaron Newton wrote:
>
>
>
> > On Tue, Sep 8, 2009 at 1:33 PM, H13 <[email protected]> wrote:
>
> > Hi, did you read the post.
>
> > Of course that I use:
> > $$('form.formclass').addEvent('submit', function(e){
> > new Event(e).stop();
>
> > I am not trying to solve problem with submit button. I am trying to
> > solve problem with starting submit button with URL link.
>
> > So, if you click on URL, with help of onlclick="$('formid').submit()
> > you should run the submit process which will be catched by submit
> > event:
> > $$('form.formclass').addEvent('submit', function(e){
> > new Event(e).stop();
>
> > BUT THE PROBLEM IS NOT SUBMITTING THE FORM, THE PROBLEM IS THAT IF YOU
> > RUN SUMBIT BUTTON WITH HELP OF URL (ONCLICK) THEN THE SUBMIT EVENT
> > WILL BE NOT CATCHED BY MOOTOOLS :-(
>
> > in that case you do need to use fireEvent('submit'). Note that this
> > will not pass along an event object to call preventDefault or stop on.