Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Dynamic loading one class in another using contentPanel.load() AND Auth info!

  1. #1
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Question Dynamic loading one class in another using contentPanel.load() AND Auth info!

    Hi,
    i have a problem with design of "core" javascript part. I have class which is loaded at startup and fetch menu placed at north from JSON data. In center region is a place for content dynamicaly loaded from menu.

    That all works great and its not a problem. Im using ContentPanel.load() method with scripts: true. Problem is, that the load() calls callback (there is called init function with result 'is not defined' - from firebug console later its ok) before the script inside is initialized. Is there any event or some way to get to know when script inside is initialized? Or is there another way to get it? I need to execute content to make UI of clicked module.

    I searched all forum for 2 days but now im helpless..

    Any help or link would be appreciated.


    EDIT: Dont care 'bout TV window at bottom right
    Attached Images Attached Images

  2. #2
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default

    I think i made it...just add execution function to loaded document...so i hope it will be ok

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    136

    Default

    Just a hint, source is not tested, but I use this source inside my test playground and it works great
    Code:
    App.layout.beginUpdate();
    var cp = new Ext.ContentPanel('cp', {autoCreate: true, fitToFrame:true, autoScroll:true, title:'Content Panel', closable:true, disableTooltips: true });
    var umgr = cp.getUpdateManager();
    var url = 'http://your.url.com';
    umgr.loadScripts = true;
    umgr.setDefaultUrl(url);
    umgr.refresh();
    App.layout.add(layout.getRegion('west'), cp);
    App.layout.endUpdate();

  4. #4
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default

    Hey, thanks for reply..

    im using it at similar way but problem is that LOAD event fires even if javascript inside is not itialized...

    part of my code:
    Code:
    newPanel: function( id, title, url ) {
    	if ( !Ext.get(id) ) {
    		var div = Ext.DomHelper.append( paneContent, {tag: 'div', id: id} );
    		this.panels[id] = new Ext.ContentPanel( div, {title: title, fitToFrame:true, closable:true} );
    		layout.add('center', this.panels[id]);
    		this.panels[id].load( {url: url, scripts: true, text: "Loading.."} );
    
    		// This fires even if JS inside is not initialized
    		this.panels[id].on('load', this.execLoadedPanelContent);
    	} else {
    		//var div = Ext.get(id);
    		layout.add('center', this.panels[id]);
    	}
    }
    hope it will help someone

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The load event will fire on load. That's what it is supposed to do.

    What problem are you solving? There's a better way.

  6. #6
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Red face

    Quote Originally Posted by Animal View Post
    The load event will fire on load. That's what it is supposed to do.
    What problem are you solving? There's a better way.
    Thanks for reply animal. The problem i have is that i need to call CHILD.init() after contentPanel is fully loaded (include javascript) and all objects are defined. CHILD.init() is defined in code that loads in contetnPanel with .load() method.
    I have set the .on('load'... but in time of object's onLoad fired that have to be loaded object is not initialized...

    In this time i have it solved by this code which is placed as last in loaded (child) file

    Code:
    Ext.EventManager.onDocumentReady(CHILD.init, CHILD);
    it works but i dont know if its ok and if it is safe (if it will work every time)





    And Animal (or anyone else ) if i can, i have a second problem that i cant get succefully solved (i hope last ).
    I cant intercept the right function to check responseText in every time any response came back (include standard way to make page grid - JSONdataStore). I just want to check auth info in every response and not to check it periodically like now. I tried to got answers on other topic so in order to maintain topic and if anyone knows solution we can discuss it here http://extjs.com/forum/showthread.ph...ght=user+still (check last page - page3 - only)

    Any ideas?
    Thanks so much..

  7. #7
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default

    Noone knows?

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    You don't need an onReady if you are executing code that is loaded into a Contentpanel. The document is ready! The method will be called immediately.

    To check response subscribe to the "requestcomplete" event of the Proxy's Ext.data.Connection object. (That is in the "conn" property of the Proxy).

    The event is passed the Connection, the response and the options.

    I've noticed that the events are not in the API docs for Connection, so I'll fix that, so you can see all this in the next round of doc updates.

  9. #9
    Ext User
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default

    Wow, thanks animal, thats exactly what i want to hear. I'll try it. Thank you so much.
    And what about docs update? Do you know approximate time when it will be probably done?

  10. #10
    Sencha User
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I don't know. But Jack and Brian really seem to be polishing up the code in SVN, so it can't be long.

Page 1 of 2 12 LastLast

Posting Permissions

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