Hi, I'm guessing you're not in control of the HTML generation (e.g., you're getting it from some other thing -- a content management solution, another site, whatever -- and don't have direct control over it). If you *are* in control of the HTML generation, just don't output the onclick attribute in the first place.
This came up a while back in the forums: Wanting to supersede a DOM0 event handler (e.g., a handler assigned via onclick rather than more modern ways like those used by Element#observe). Here's a function that looks for a button called btnGo and replaces its DOM0 handler with a new handler, and even chains to the DOM0 handler afterward: http://pastie.org/541315 The HTML page this would go on would have this button somewhere: <input type='button' id='btnGo' value='Go' onclick='alert("\"Go\" got clicked!");'/> Obviously that's not generalized, but it should get you pointed the right way... -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 10, 11:18 am, Stonk <[email protected]> wrote: > Hello, > > I have two buttons <button onclick="foo()" class="save" > id="random_number"> and want to add an observer and fire an own > function (bar()). When this function is completed, foo() shall get > called. > I tried it with the event.stop, but that just doesn't work. > > var requestDone = false; > function bar() { > // .... > requestDone = true;} > > // Wait till page is fully loaded > Event.observe(window, 'load', function() { > saveButtons = $$('button.save'); > // Observe the Save buttons and fire the getCategories() function on > click > saveButtons.invoke('observe', 'click', function(event) { > if (false == requestDone) { > Event.stop(event); > } > }); > saveButtons.invoke('observe', 'click', bar()); > > }); > > Could anyone please point me in the right direction? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
