Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Stopping default action
- From: moseley at hank.org (Bill Moseley)
- Subject: [Javascript] Stopping default action
- Date: Fri Mar 31 00:43:50 2006
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@xxxxxxxx
- Follow-Ups:
- [Javascript] Stopping default action
- From: Mike Dougherty
- [Javascript] Stopping default action
- References:
- [Javascript] Stopping default action
- From: Bill Moseley
- [Javascript] Stopping default action
- From: Mike Dougherty
- [Javascript] Stopping default action
- Prev by Date: [Javascript] Stopping default action
- Next by Date: [Javascript] Stopping default action
- Previous by thread: [Javascript] Stopping default action
- Next by thread: [Javascript] Stopping default action
- Index(es):