Results 1 to 6 of 6

Thread: autoLoad url and html parameters to use id.

  1. #1

    Default autoLoad url and html parameters to use id.

    hello,

    how can I use the id in div tag in the following code:

    .........
    autoLoad: {url: "test.html", callback: this.initSearch, scope: this, scripts: true},

    or

    html: '<div id="div1"></div>',
    .......


    test.html is: <div id="div1"></div>
    ....


    neither : var myDiv = Ext.get('div1');
    nor : document.getElementById("div1");

    can find the id div1 !!!!! ????
    thank you.

  2. #2
    Sencha User asp3ctus's Avatar
    Join Date
    Jan 2010
    Location
    Russia
    Posts
    28

    Default

    I didn't understood the question, my English isn't perfect ....
    I understand you trying to get the component ... but their is this div declared ?

    Is it in html file it self? is so you should have get it using Ext.get()
    I don't get what is autoLoad have to do with ?
    What xtype are you using with this property?
    please give more code and i try to help my best )))

  3. #3

    Post

    Ext.onReady(function(){

    var SamplePanel = Ext.extend(Ext.Panel, {
    width: 500,
    height:250,
    style: 'margin-top:15px',
    bodyStyle: 'padding:10px',
    renderTo: 'docbody', // <body id="docbody">
    autoLoad: {url: "test.html", callback: this.initSearch, scope: this, scripts: true},
    //test.html contains : <div id "div1">it's just a test</div>
    // or html: '<div id "div1">it's just a test</div>', Instead of autoLoad

    autoScroll: true
    });


    new SamplePanel({
    title: 'Test'
    });
    // Now if I want to do something like this :

    var myDiv = Ext.get('div1');
    myDiv.highlight();
    // or
    alert(document.getElementById("div1").innerHTML);

    // div1 is missed, and the code dont work.


    });


    how can I do to call the id div1 !!??

    thank you again.

  4. #4
    Sencha User asp3ctus's Avatar
    Join Date
    Jan 2010
    Location
    Russia
    Posts
    28

    Default

    Ok ... so you have a mistaken <div id "div1">it's just a test</div> for <div id="div1">it's just a test</div>

    And you need to make a func
    testFunc = function() {
    alert(document.getElementById("div1").innerHTML);
    }


    And add it to the listener for afterrender event like

    new SamplePanel({
    title: 'Test',
    listeners : {
    afterrender : function(){ testFunc(); }, scope: this}
    }
    });

    You might have small probs with scope .. play around with firebug to call the func to see that it is working _)))

  5. #5

    Default

    Thank you asp3ctus for your answer,

    id="div1" is just one forgets, but I did it right in my program.

    apparently when I use :

    testFunc = function() {
    alert(document.getElementById("div1").innerHTML);
    }

    with:
    ......
    bodyStyle: 'padding:10px',
    renderTo: 'docbody',
    html: '<div id="div1">it's just a test</div>',
    autoScroll: true
    ......

    it work ,

    but not with : autoLoad: {url: "test.html", scripts: true},

    Sorry, but can you tell me more about autoLoad !! I didnt find anything with firebug, maybe cause I cannot use it correctly =p.

  6. #6

    Default

    I I found it

    autoLoad: {url: "test.html", scripts: true,callback: this.testFunc,scope: this}

    now it's working :p , thank you for all.

Posting Permissions

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