[Javascript] Stopping default action

Mike Dougherty mdougherty at pbp.com
Fri Mar 31 07:06:32 CST 2006


If you are building a Ajax as a workaround for inline clicks then you are working way too hard...
you can deliver semantic markup without the clutter of javascript function registration and an 
external script that attaches events to the controls without using ajax.  I'm not sure what you 
meant by "...get rid of my inline onclicks"

If you are concerned that your ajax control would get called more than once, you could write the 
control to process a queue (array).  the calling routines would put requests into the queue and 
the ajax control would process each entry from the queue one at a time.  Hopefully your app is not 
so dynamic and your server so slow that the queue ever gets more than 2-3 tasks deep.


On Thu, 30 Mar 2006 22:43:41 -0800
  Bill Moseley <moseley at hank.org> wrote:
> On Thu, Mar 30, 2006 at 06:48:32PM -0500, Mike Dougherty wrote:
>> I just had a reason to research this myself...
>> 
>> http://www.gerd-riesselmann.net/archives/2005/03/a-firefox-javascript-bug
>> 
>> Read the author's thoughts describing your problem, then see the first 
>> comment for the (obvious?) solution.  :)
> 
> Thanks.   I also came across that during my wild google chase for
> ideas.
> 
> So I'm using this to set my ajax events:
> 
>    function updater( linkID, target ) {
> 
>        var el = $(linkID);
>        var url = el.href;
> 
>        var my_update = function(e) {
>            e.preventDefault();
> 
>            new Ajax.Updater( target, url,
>                {
>                    evalScripts: true,
>                    method: 'get',
>                    requestHeaders: ['X-Ajax-Updater', 'ajax_table']
>                });
> 
>            return false;
>        }
> 
> 
>        Event.observe( linkID, 'click', my_update, 'false' );
>    }
> 
> Not thrilled about using evalScripts.  It's needed to reset the events
> after the ajax update (the update replaces those elements).  That
> requires the ajax response to include a <script> section with fresh
> calls to updater().
> 
> Right now none of my ajax updates change the links (or their ids) so
> I'm thinking about saving each [linkID, target] on an array, and then
> use the onComplete feature of Ajax.Updater to reload those events
> after the ajax update.  That would avoid having to send <script> in
> the ajax response.
> 
> But, then there's a risk I might call updater() again for a now
> non-existent link, or add another event for a link that was not
> updated by the ajax call -- ending up with multiple events.
> 
> Kind of a bother for just trying to get rid of my inline onclicks. ;)
> Separation of behavior and structure, so they say...
> 
> 
> 
> -- 
> Bill Moseley
> moseley at hank.org
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> 
> __________________________________________________________
> This message was scanned by ATX
> 1:43:59 AM ET - 3/31/2006




More information about the Javascript mailing list