1. #1
    Ext User
    Join Date
    Jul 2007
    Posts
    10
    Vote Rating
    0
    rogrdat is on a distinguished road

      0  

    Question Ext.get() in Frames

    Ext.get() in Frames


    document.getElementById() works, but Ext.get() doesn't when I'm working in frames (my grid and other ext components are displayed within a page that is inside a frameset). Any ideas to overcome this...,

    thanks,
    rogr

  2. #2
    Sencha User
    Join Date
    Apr 2007
    Location
    Italy/UK
    Posts
    152
    Vote Rating
    0
    sj137 is on a distinguished road

      0  

    Smile


    Hi, check out the Using Layouts tutorial : http://extjs.com/learn/Tutorial:Usin...h_Ext_-_Part_1

    there is a script that may help you, copied below:

    PHP Code:
    function getIframeDocument(el) {
        var 
    oIframe Ext.get('center-iframe').dom;
        var 
    oDoc oIframe.contentWindow || oIframe.contentDocument;
        if(
    oDoc.document) {
            
    oDoc oDoc.document;
        }
        return 
    oDoc;

    best regards, SJ

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Not really safe. Ext isn't designed to handle multiple documents.

    Ext.Elements are cached keyed by their id which is unique for the current document. If there is another element by the same id in another document this will cause a problem.

  4. #4
    Sencha User
    Join Date
    Apr 2007
    Location
    Italy/UK
    Posts
    152
    Vote Rating
    0
    sj137 is on a distinguished road

      0  

    Default


    i use this function call to get to variables and methods in my iframe:

    Ext.getDom('center-iframe').contentWindow.myvar

    Ext.getDom('center-iframe').contentWindow.mymethod()

    not sure if this is really useful to you, tho i suppose you could write a method in your iframe to change characteristics of dom elements and pass it the id of the elements you want to change, or there maybe a better way...

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    10
    Vote Rating
    0
    rogrdat is on a distinguished road

      0  

    Default


    sj137,

    Thanks for the info and I could use that approach in my code when I want to reference a variable. However the problem that I sometimes run into is ExtJS code internally uses Ext.get() and similar functions that do not take into consideration that it might be getting executed within a Frame. I am looking for a way by which I can direct the Ext package to look at only a particular frame, something like

    Code:
    // Ext's Root node points to the root for the frame. 
    Ext.dom = top.contentframe.window;  // contentframe is the id of the frame
    This way any calls to Ext.get() will only reference variables in that particular frame. Just keep in mind that all my Ext code runs only in that frame.

Thread Participants: 2