PDA

View Full Version : Handling an event on an element and stopping it from being fired on the component.



FoxMulder900
15 Oct 2012, 7:49 AM
Hello,
I am trying to set up a simple "help mode" on my application. I want the user to be able to click on a help button in the top left of the viewport, then the user should be able to click any component in the application to display some short help text on that component.

Here is the handler I currently have for the help button.

toggleHelpMode: function(btn,e){
e.stopEvent();
btn.up('viewport').el.on('click',function(e,el){
e.stopEvent();
alert('Display some help text for '+ el.id);
},this,{
stopEvent: true,
single: true
});
}

As you can see, when the button is clicked, I add a one-time event handler to the viewport. So the next click should be captured and I can display text based on the element that was passed in the click function. However, let's say I click on a button, the button's click handler is still called even though I am calling e.stopEvent() AND added stopEvent: true in the event options.

Is there something I am missing to stop the event? Or are events on elements handled separately than component events? Any suggestions would be appreciated!