Ext.query help

  • I need to find any form tag that does not have an onSubmit and add an onSubmit to it.

    What I have so far is:


    Ext.onReady(function() {
    formElem = Ext.query("form[onSubmit]");
    if (formElem) {
    alert("YES");
    } else {
    alert("NO");
    }
    });


    But it is always returning yes. I read the API docs and some tutorials and tried curlys as well with no luck.

    Any help is appreciated. Also if someone can point me to an API doc on adding an attr to a tag I would be very thankful as I could not find it.

    Thanks!

    Jim


  • Ext.query returns array so your test should look like if(formElem.length) { ... }. See http://extjs.com/deploy/dev/docs/?class=Ext&member=query for details.


  • Josef,

    Thank you...I did discover that and was about to post that....thank you though...very much appreciated. How would I go about adding an onSubmit attribute to the form tag? I see appending...but not sure how to use that when working within a tag.

    THanks!

    Jim


  • Well, you could use setAttribute but I'm missing the purpose of doing this while you have the whole Ext form infrastructure on hand.