Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Answers
    1
    Vote Rating
    0
    eddyystop is on a distinguished road

      0  

    Default Answered: Why doesn't 'Ext.Msg.alert(...)' work while 'Ext.Msg.prompt()' does?

    Answered: Why doesn't 'Ext.Msg.alert(...)' work while 'Ext.Msg.prompt()' does?


    I'm just starting with Ext JS and trying to understand the why's of the following using Ext4.

    These work:
    Ext.Msg.prompt('...', '...', fn);
    Ext.Msg.show({...});

    But this doesn't work in the latest Chrome and FF:
    Ext.Msg.alert('...', '...', fn);
    Chrome gives the console msg: Cannot call method 'alert' of undefined.
    Why?

    So I'm using:
    Ext.create('Ext.window.MessageBox').alert('...', '...', fn);

  2. Thank you Chamacs.
    The following is my new noobie understanding. I'm most uncertain about the very last paragraph. Please correct me if I'm wrong. Thanks.

    I can use
    Ext.Msg.alert('...', '...', fn);

    (a) with the brute-force way using
    Code:
    <script type="text/javascript" src="../../extjs/ext-all-debug.js"></script>
    or ext-all-dev.js or ext-all.js

    (b) with dynamic loading using
    Code:
    <script type="text/javascript" src="../../extjs/ext-dev.js"></script>
    or ext-debug.js or ext.js
    Code:
    <script type="text/javascript">
    // A leading script tag is used to ensure this is all loaded before
    // the following script starts executing.
    Ext.Loader.setConfig({
        enabled        : true,
        disableCaching : false,
        paths          : {
            // relative path where to find 'Ext.xxx' thingies
            'Ext' : '../../extjs/src'
        }
    });
    // Do asynchronous loading of classes we know we'll need
    Ext.require('Ext.window.MessageBox');
    </script>
    Code:
    <script type="text/javascript">
    Ext.onReady(function () {
    
    
    // Following gives: TypeError: Obj fcn () {...} has no method alert
    // because 'Ext.window.MessageBox' is a class, while
    // 'Ext.MessageBox' is a singleton instance of it, while
    // 'Ext.Msg' is a convenience alternate name for 'Ext.MessageBox'
    //    Ext.window.MessageBox.alert('Hello.', 'The DOM is ready');
    
    
    // Following also work   
    //    Ext.Msg.alert('Hello.', 'The DOM is ready');
    //    Ext.MessageBox.alert('Hello.', 'The DOM is ready');
    
    
    // If Ext.require does not exist above, this synchronously loads the class on demand
    // If Ext.require exists above, Ext.Loader knows class is loaded already
        var win = Ext.create('Ext.window.MessageBox');
        win.alert('Hello.', 'The DOM is ready!'); 
    
    
    });
    </script>
    My main uncertainty: Ext.window.MessageBox is a class (implemented as a function) and so you cannot use .alert on it. Ext.MessageBox and Ext.Msg are the same singleton instance (implemented as an object) of the class (via 'new') and so .alert can be called on them.

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    Grenoble (France)
    Posts
    20
    Vote Rating
    0
    GBenji is on a distinguished road

      0  

    Default


    Cause Ext.Msg is define as singleton instance of Ext.window.MessageBox but it's not an alias.

    Try with (easier than your solution) : Ext.MessageBox.alert('...','...','fn');

    (i'm just an user, so don't put your life in my hands :p)

  4. #3
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    @GBenji,

    Ext.MessageBox and Ext.Msg are the same.


  5. #4
    Sencha User
    Join Date
    Jan 2012
    Location
    Grenoble (France)
    Posts
    20
    Vote Rating
    0
    GBenji is on a distinguished road

      0  

    Default


    Edit : nothing

  6. #5
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    This works perfectly for me in FF, Chrome and IE:

    Code:
    Ext.Msg.alert('Test!', 'Test Message', function() { console.log('alerted!') });
    After clicking the alert's 'ok' button, the function executes and I see the console log message.

  7. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Answers
    1
    Vote Rating
    0
    eddyystop is on a distinguished road

      0  

    Default


    Thanks everyone for replying.

    GBenji:
    None of these work for me:
    // Ext.create('Ext.Msg').alert('Hello.', 'The DOM is ready!');
    // Ext.Msg.alert('Hello.', 'The DOM is ready!');
    // Ext.window.MessageBox.alert('Hello.', 'The DOM is ready!');
    // Ext.MessageBox.alert('Hello.', 'The DOM is ready!');

    friend:
    I don't understand why your
    Ext.Msg.alert('Test!', 'Test Message', function() { console.log('alerted!') });
    works. I'm now trying to run the following inside the HTML page:

    <link rel="stylesheet" type="text/css" href="../../extjs/resources/css/ext-all.css">
    <script type="text/javascript" src="../../extjs/ext-debug.js"></script>
    <script type="text/javascript">
    Ext.onReady(function () {
    Ext.Msg.alert('Hello.', 'The DOM is ready!', function () {
    console.log('Ext.window.MessageBox.alert closed.');
    });
    });
    </script>

    and on Chrome get:
    ex020102.html:13Uncaught TypeError: Cannot call method 'alert' of undefined
    Last edited by eddyystop; 29 Feb 2012 at 7:04 AM. Reason: indented code

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi