"Say, when clicking on a letter in the Mini keyboard, it would first remove
the handler triggering the instant correction, add the letter to the field
input, and finally add the previously removed handler..."

The onchange event will be triggered before the onclick handler is performed
:
1°) user is writing in the input field
2°) user clicks on the mini keyboard
3°) input field lose focus
4°) input field's onchange event is triggered
5°) mini keyboard has focus
6°) mini keyboard's onclick handler is performed

In the onchange handler, the document.activeElement is the body element, not
the mini keyboard.

What should be the solution with the class name check ?
On Wed, Dec 8, 2010 at 09:08, Stephane Eybert <[email protected]>wrote:

> Would there be any way to dynamically add and remove the handler using
> jQuery ?
>
> Say, when clicking on a letter in the Mini keyboard, it would first remove
> the handler triggering the instant correction, add the letter to the field
> input, and finally add the previously removed handler...
>
>
>
> ------------------------------
> *De :* Eric Pascarello <[email protected]>
> *À :* [email protected]
> *Envoyé le :* Mar 7 décembre 2010, 22h 12min 29s
> *Objet :* Re: [JSMentors] Re : Re : Re : Not triggering an onchange
> handler
>
> Trying to do anything with the click events is too late. The onchange event
> is fired before the event happens.
>
> You would need to handle the logic inside of the onchange handler to see
> what element has focus. Only issue is browsers set document.activeElement
> differently so it is not as easy to see if that element is your button/link.
>
> Eric
>
>
>
>
>
> On Tue, Dec 7, 2010 at 11:40 AM, Stephane Eybert 
> <[email protected]>wrote:
>
>> Hi Christophe,
>>
>> Thanks for your comment, I must say I tried to have some return false in
>> the
>> method as
>>
>>  $('.no_style_keyboard_letter').click(function(event) {
>>    typeTextIntoFocusedElement($(this).attr("letter"));
>>     return false;
>>  });
>>
>> but no luck.
>>
>> Same with
>>
>> <a href="javascript:typeTextIntoFocusedElement('&#224;');return false;"
>> title='$caption'> &#224; </a>
>>
>> I admit I shot in the dark here.
>>
>> I own all the code so I could re-architect it if needed.
>>
>> I shall keep trying.
>>
>> Thanks again.
>>
>> Stephane
>>
>>
>>
>>
>>
>> ----- Message d'origine ----
>> De : Christophe Porteneuve <[email protected]>
>> À : [email protected]
>> Envoyé le : Mar 7 décembre 2010, 15h 38min 14s
>> Objet : Re: [JSMentors] Re :  Re : Not triggering an onchange handler
>>
>> OK, preventing the event from being fired.  Actually you don't care about
>> its
>> being fired (and it WILL be), but about its being DETECTED.
>>
>> Depends on your browser.  If you don't have to support IE, you can capture
>> that
>> event and censor it when appropriate.
>>
>> You likely DO have to support IE, however, so the question is more about
>> "who's
>> paying attention?".  If it's done at a higher level in the DOM (some
>> ancestor
>> element, perhaps document itself), then just listen for it closer to the
>> source
>> field (perhaps the field itself) and censor its bubbling when appropriate
>> (jQuery would have your function return false to do this; the W3C
>> standard, and
>> Prototype's preferred way as well, is to call the event object's
>> stopPropagation() method; etc.)
>>
>> If you already have event listeners in place straight on the field, well,
>> I
>> don't know of a way to prevent those from getting triggered on field
>> change
>> (which, as a reminder, only happens on blur for text fields).
>>
>> 'HTH
>>
>> -- Christophe Porteneuve
>> [email protected]
>>
>> _______________________________________________
>> JSMentors mailing list
>> [email protected]
>> http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
>>
>>
>>
>>
>>
>> _______________________________________________
>> JSMentors mailing list
>> [email protected]
>> http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
>>
>
>
>
> _______________________________________________
> JSMentors mailing list
> [email protected]
> http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
>
> List Archive:
> http://jsmentors.com/pipermail/jsmentors_jsmentors.com/
>
_______________________________________________
JSMentors mailing list
[email protected]
http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com

List Archive:
http://jsmentors.com/pipermail/jsmentors_jsmentors.com/

Reply via email to