Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    41
    Vote Rating
    0
    jonx is on a distinguished road

      0  

    Question Understand the basics: access to an existing button in my page

    Understand the basics: access to an existing button in my page


    Hello,
    I'm trying to learn JS. It's hard. Maybe I'm dumb but I'm unable to find a very basic thing. I tried the docs, the samples, the API, the forum... Probably that my question is so basic that it must look trivial to all of you.

    Here it comes. I do not understand how to access to an existing element in my page and get it correctly typed.

    What I want is simple, still, I think

    I have an HTML button in my page:
    HTML Code:
    <input type="submit" id="btnLaunch" value="Lancer" name="btnLaunch"/>
    I want to get my hands on the button and change its label.

    What I tried is:
    PHP Code:
     var buttonLaunch Ext.get('btnLaunch'); 
    But if I understand things correctly, this gives me an Ext.Element. Meaning when I try to do:
    PHP Code:
    var buttonLaunch Ext.get('btnLaunch').setText('a test'); 
    It says that my component doesn't have that method set. That's right because that method is a method from the Button class.
    I also tried things like:
    PHP Code:
    Ext.get('btnLaunch').Text 'a test'
    this does not do anything. No error, no label change.

    Right. So. How do I get access to my button as a Button ? There are plenty of samples here about how to create new things but I can see how to acees to existing things (other then of type Ext.Element).

    I would love two things to help learn to learn

    How do I access to a componant by strong type?
    How do I change its properties?
    Where on the ExtJS web site should I have found the information?

    Thanks a lot for your help in advance...

  2. #2
    Ext User
    Join Date
    Mar 2008
    Posts
    41
    Vote Rating
    0
    jonx is on a distinguished road

      0  

    Default


    Ok, maybe a hint, I just found in the FAQ that I should use getCmp to get typed components.

    I tried:
    PHP Code:
    var btn Ext.getCmp('show-btn');
    btn.setText('a test'); 
    but this tells me that btn is null. What are the conditions for a component to be found?

    Any hint? Thank you.

  3. #3
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    573
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    jonx,

    your
    HTML Code:
    <input type="submit" id="btnLaunch" value="Lancer" name="btnLaunch"/>
    is NOT an Ext.Button.

    An Ext.Button looks quite differently in HTML e.g. this is a button of one of my ExtJS applications
    HTML Code:
    <table cellspacing="0" cellpadding="0" border="0" class="x-btn-wrap x-btn x-btn-text-icon" id="ext-comp-1169" style="width: auto;"><tbody><tr><td class="x-btn-left"><i> </i></td><td class="x-btn-center"><em unselectable="on"><button type="button" class="x-btn-text" id="ext-gen138" style="background-image: url(/img/settings.gif);">Profile</button></em></td><td class="x-btn-right"><i> </i></td></tr></tbody></table>
    Ext.Button needs all those extra HTML to do it's work. Your normal HTML submit input element (not even a HTML button element ) can only be accessed as Ext.Element:

    PHP Code:
    Ext.get('btnLaunch').dom.value 'a test'

    Ext.getCmp() can only get you the button object if you created that somewhere else.
    E.g. I create the button mentioned above with
    PHP Code:
    new Ext.Button({
                    
    id:'settings-button',
                    
    text'Profile',
                    
    cls"x-btn-text-icon",
                    
    iconMMEPR.baseUrl "img/settings.gif",
                    
    handlerthis.showSettings,
                    
    scopethis,
                    
    renderTocontainer
                
    }); 
    and can later get a reference to it with
    PHP Code:
    var button Ext.getCmp('settings-button'); 

  4. #4
    Ext User
    Join Date
    Mar 2008
    Posts
    41
    Vote Rating
    0
    jonx is on a distinguished road

      0  

    Thumbs up


    Thank you for your help DJ, that makes perfect sense.

    It's sad that this can be found nowhere in the "documentation". At least I didn't find it. Maybe it's somewhere but it should be much better advertized as this is not obvious for a beginner.

  5. #5
    Ext User
    Join Date
    Mar 2008
    Posts
    41
    Vote Rating
    0
    jonx is on a distinguished road

      0  

    Thumbs up


    I added this entry to the FAQ:
    How to access existing HTML components

    I hope you don't mind being quoted or else I'll remove it.

    Thanks again.

  6. #6
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    573
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    I don't mind at all. I'm glad I could help

Thread Participants: 1