I am trying to enhance a HTML textarea with some BB-Code controls that should only be available when the textarea has focus. The desired behaviour looks like this:
Picture 1 - before focus event:
(source: gaedekenet.de)
Picture 2 - after focus event (correct behaviour):
(source: gaedekenet.de)
The above correct behaviour is accomplished by clicking in the LOWER part of the textarea - where no buttons will appear. But whenever the user clicks in the top left part of the textarea, the following will happen:
Picture 3 - after focus event (incorrect behaviour):
(source: gaedekenet.de)
It seems to me that not only the "focus" event is triggered but also "click", "mousedown", "mouseup", etc.
What I need to do now, is to stop the event propagation in my own code (the focus part) so that no events can reach the BB Code plugin (which is a 3rd party plugin). My current approach looks like this:
$(#myText)
.focus(function(e){
e.stopPropagation().stopImmediatePropagation();
// initialize and show the bb code buttons here
})
.click(function(e){
e.stopPropagation().stopImmediatePropagation();
})
.mouseup(function(e){
e.stopPropagation().stopImmediatePropagation();
})
.mousedown(function(e){
e.stopPropagation().stopImmediatePropagation();
});
What am I missing?