1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    e.e.coli is on a distinguished road

      0  

    Default DomHelper: cannot create a label tag

    DomHelper: cannot create a label tag


    Captain, I canna

    Code:
    dh.append(myThang, {tag: 'label, for: 'anything'});
    because 'for' is a reserved word, but is also a required attribute for a label tag.

    Cheers.

  2. #2
    Ext User
    Join Date
    Mar 2007
    Posts
    22
    Vote Rating
    0
    KuN is on a distinguished road

      0  

    Default


    'for':'anything'
    doesnt work?

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    e.e.coli is on a distinguished road

      0  

    Default


    Well, dip me in cornflour and deep fry me. It does work.

    Excuse me, Jack, KuN, and all.

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    e.e.coli is on a distinguished road

      0  

    Default


    'for':'anything'
    doesnt work?
    Ach, in fact it does not work... in IE 6 and in an older Firefox. "for" is indeed a reserved word, and is not permitted as a property identifier in an object.

    Jack, if you're reading this, my current workaround is to patch DomHelper something like

    Code:
                if(attr == 'cls'){
                    b += ' class="' + o['cls'] + '"';
                }else if(attr == 'forfield'){
                    b += ' for="' + o[attr] + '"';
                }else{
                    b += ' ' + attr + '="' + o[attr] + '"';
                }
    and

    Code:
               if(attr=='cls'){
                    el.className = o['cls'];
                }else if (attr=='forfield') {
                	el.htmlFor = o['forfield'];
                }else{
                    if(useSet) el.setAttribute(attr, o[attr]);
                    else el[attr] = o[attr];
                }
    I'm not advocating for "forfield" as a "good" solution; I trust your aesthetics about that.
    Cheers.

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    e.e.coli is on a distinguished road

      0  

    Default


    Better yet, if you use
    Code:
    htmlFor
    as the special property, you only have to patch the html gen side, not the dom side.

  6. #6
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    I have never run into an error using 'for', but it doesn't surprise me that it could throw an error.

    I used the htmlFor patch. Thanks for posting it.

    Code:
                ...
                if(attr == 'cls'){
                    b += ' class="' + o['cls'] + '"';
                }else if(attr == 'htmlFor'){
                    b += ' for="' + o['htmlFor'] + '"';
                }else{
                    b += ' ' + attr + '="' + o[attr] + '"';
                }
                ...

  7. #7
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    e.e.coli is on a distinguished road

      0  

    Default


    I used the htmlFor patch. Thanks for posting it.
    You are most welcome. It's a tiny drop in the ext bucket.

Similar Threads

  1. how to create element in dom
    By humpdi in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 29 Mar 2007, 11:13 PM
  2. create entire UI without ids?
    By em_te in forum Ext 1.x: Help & Discussion
    Replies: 16
    Last Post: 28 Mar 2007, 10:47 AM
  3. How to give spacing between Label and TextField in Form ?
    By saasira in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 12 Mar 2007, 10:35 PM
  4. Add a wait gif to a tab label
    By dmayer in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 20 Nov 2006, 1:42 PM

Thread Participants: 2