Results 1 to 2 of 2

Thread: how to use correctly insertBefore::DomHelper with the UM??

  1. #1

    Default how to use correctly insertBefore::DomHelper with the UM??

    i'm using this code:
    Code:
    var rListMsgs = new function(){
    	this.render = function(el, response){
    	var dh = YAHOO.ext.DomHelper;
    	var obj = response.responseText;
    	obj=obj.split("\n");
    	for (v in obj)
    	dh.insertBefore('item0', {tag: 'li', html: obj[v]});
    	}
    	}();
    
    var dh = YAHOO.ext.DomHelper;
    dh.append('container',{tag:'div',id:'room', html:'prova'});
    dh.append('room', {tag: 'ul', children: [
    						  {tag: 'li', id: 'item0', html: 'List Item 0'}
    						  ]
    					});					
    room = getEl("room").getUpdateManager();;
    room.setRenderer(rListMsgs);
    room.update('msg.php');
    room.startAutoRefresh(4,'msg.php');
    to try to add before the element item0 inside the list in the room div other elements to the list

    [dom tree]

    -div (room)
    --ul
    <-- here i wanna be
    ---li (item0)
    [/dom tree]

    the code don't work.. :cry:

    also if i use .append method it only replace the whole room content and not - as i would - only add li elements to the ul inside room div

    what is wrong?

    ps:

    msg.php output is:
    Code:
    item1
    item2
    ....
    ....
    ...

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    You will want to get the update manager for the UL, not the "room".

    ...
    var ul = dh.append('room', {tag: 'ul', children: [
    {tag: 'li', id: 'item0', html: 'List Item 0'}]}, true);

    var um = ul.getUpdateManager();;
    um.setRenderer(rListMsgs);
    um.update('msg.php');
    um.startAutoRefresh(4,'msg.php');

    We can get the UL by assigning a var to the return value. We pass true as the third parameter to say we want an Element back (0.33 beta 1+). The rest is the same but changed to the ul's UpdateManager.

Similar Threads

  1. Am I using Grid.afteredit correctly?
    By gordon in forum Ext 2.x: Help & Discussion
    Replies: 18
    Last Post: 5 Aug 2009, 12:05 PM
  2. Field dom id not being set correctly? (alpha 3 rev 4)
    By ericwaldheim in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 30 Mar 2007, 10:50 AM
  3. DomHelper help Please
    By hunkybill in forum Ext 1.x: Help & Discussion
    Replies: 8
    Last Post: 17 Nov 2006, 8:30 PM
  4. Replies: 2
    Last Post: 5 Nov 2006, 3:29 AM
  5. DomHelper
    By INeedADip in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 18 Oct 2006, 2:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •