Its not super pretty but you can do this too:

function processFormAjaxCall(remoteUrl, targetDiv, formId, method) {
               alert("form submit" + remoteUrl + ":" + targetDiv);
               var request = new Request.HTML({
                   url: remoteUrl,
                   update: targetDiv,
                   method: method
               });
               request.post($(formId)); //This code is executing more than
once
               *return false;*
}


<a id="addAtty" href="#" class="addmore"
onclick="*return*processFormAjaxCall('addMoreItems.action',
'resultList','frmId','POST' )">

returning false will do the same thing as the stop method.

I would NOT recommend you to use this. You should always try to use
unobstrusive javascript. You shouldnt mix javascript into your html, thats a
bad practice. And you shoudnt be creating an instance of a request at each
user click.

Theres no way around hardcoding the ids from the elements. Or you use a
richfaces kind of thing or youll have to harcode your ids. Thats my opnion
but maybe someone has a better solution.

--
Fábio Miranda Costa
Solucione Sistemas
Engenheiro de interfaces


On Fri, Mar 19, 2010 at 3:18 PM, praveen <[email protected]> wrote:

> how to stop adding events?. I want to run only one time. is there any
> thing wrong i am doing?
>
> On Mar 19, 1:54 pm, "Matthew Hazlett" <[email protected]> wrote:
> > That's easy, your code is adding the event each time.  Each time the link
> is
> > clicked it adds a new copy of the event.
> >
> > The 4th time there will be 4 events..  etc
> >
> > -----Original Message-----
> > From: [email protected]
> >
> > [mailto:[email protected]] On Behalf Of praveen
> > Sent: Friday, March 19, 2010 1:44 PM
> > To: MooTools Users
> > Subject: [Moo] ajax submit issue
> >
> > Hi, I am submiting a form on click of hyperlink using ajax call. the
> > issue is, first time it works fine. Second time i click the link the
> > event is firing twice and submiting twice. 3rd time it submits 3
> > times..and so on..I am not getting why it is happening. Here is the
> > hyperlink and its code.. Let me know where i am doing wrong.
> >
> >         function processFormAjaxCall(remoteUrl, targetDiv, formId,
> method) {
> >                 alert("form submit" + remoteUrl + ":" + targetDiv);
> >                 var request = new Request.HTML({
> >                     url: remoteUrl,
> >                     update: targetDiv,
> >                     method: method
> >                 });
> >
> >                 $('addAtty').addEvent('click', function(event){
> >                         if (event) {
> >                                 event.stop();
> >                                 event.preventDefault();
> >                         }
> >                     request.post($(formId)); //This code is executing
> more
> > than once
> > time as i keep clicking my hyperlink.
> >                 });
> >         }
> >
> > Hyperlink in my jsp look like this(like a normal link, but just
> > incase)
> >         <a id="addAtty" href="#" class="addmore"
> > onclick="processFormAjaxCall('addMoreItems.action',
> > 'resultList','frmId','POST' )">Add More Items</a>&nbsp;&nbsp;
> >
> > I click the hyperlink id: "addAtty" to trigger the ajaxcall. Please
> > let me if some help me to figure out whats happening, is it a ajax
> > issue or something else.
> >
> > To unsubscribe from this group, send email to
> > mootools-users+unsubscribegooglegroups.com or reply to this email with
> the
> > words "REMOVE ME" as the subject.
>
> To unsubscribe from this group, send email to mootools-users+
> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
> ME" as the subject.
>

To unsubscribe from this group, send email to 
mootools-users+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to