Question

I wrote this code for 508 compliance but after the users tabs off of it I want the element to go way how can I do this? here is the below:

handleInteraction:function(focusable){
    this.setElements();
    var totalAllowed = (this.elements.totalChar[0].innerHTML);
    var value = this.obj.value;
    var chars = value.length;
    var charsLeft = parseInt(totalAllowed) - parseInt(chars);
    if (charsLeft >= 0 || (typeof focusable=='boolean' && focusable==false)){
        this.elements.leftChar[0].innerHTML = charsLeft;
        this.elements.charLeftp.removeClass("error");           
    }
    else {
        this.obj.value = value.substring(0, totalAllowed);
        this.elements.leftChar[0].innerHTML = 0;
        this.elements.charLeftp.addClass("error")
        var divNA = dojo.byId("max-"+this.obj.id);
        if (divNA){
            dojo.destroy(divNA);    
        }
        divNA = dojo.create("a",{"id":"max-"+this.obj.id,"class":"hide-fromsighted","innerHTML":"<h5>This textarea has reached the maximum allowed number of characters. Please navigate backwards!</h5>","tabindex":"-1"});
        dojo.place(divNA,this.obj,'after');
        divNA.focus();


        /*
         * Here apply the onblur event to kill the <a>
         */
    }
Was it helpful?

Solution

I'm assuming you are using the Dojo Toolkit. You can destroy the <a> tag with dojo.destroy and you can use dojo.stopEvent to stop that <a> event propagation.

http://www.dojotoolkit.org/reference-guide/dojo/destroy.html#dojo-destroy

http://www.dojotoolkit.org/reference-guide/dojo/stopEvent.html#dojo-stopevent

OTHER TIPS

what about:

divNA.onblur = function() { divNA.destroy(); }

Would that work?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top