MBK
MBK

Reputation: 307

ExtJs Message box sliding of message

I came across this example in extJs. i find that they are using Ext.example.msg for the sliding to happen. So, I have decided to store the file example.js in app/ext/example/example.js

Ext.example = function(){
    var msgCt;

    function createBox(t, s){
        return ['<div class="msg">',
                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
                '</div>'].join('');
    }
    return {
        msg : function(title, format){
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
                debugger;
            }
            msgCt.alignTo(document, 't-t');
            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
            m.slideIn('t').pause(1).ghost("t", {remove:true});
        },

        init : function(){
            var t = Ext.get('exttheme');
            if(!t){ // run locally?
                return;
            }
            var theme = Cookies.get('exttheme') || 'aero';
            if(theme){
                t.dom.value = theme;
                Ext.getBody().addClass('x-'+theme);
            }
            t.on('change', function(){
                Cookies.set('exttheme', t.getValue());
                setTimeout(function(){
                    window.location.reload();
                }, 250);
            });

            var lb = Ext.get('lib-bar');
            if(lb){
                lb.show();
            }
        }
    };
}();

In index.html I have added the path <script src="./example/example.js" type="text/javascript" ></script>. I keep a debugger inside example.js. It's failing at this ( var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));) line and displaying the message Uncaught TypeError: Cannot call method 'apply' of undefined. What is this about? I have a save button in my controller and

Ext.MessageBox.alert('Save', 'xxxx', showResult);

function showResult(btn){
    debugger;
    Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
};

What is the new methodology now in ExtJs 4.2. Suggestions please.

Upvotes: 0

Views: 1391

Answers (1)

MBK
MBK

Reputation: 307

It worked. Just need to include the appropriate .css file. The location for the .css file should be specified in index.html or what ever *.html page.

Upvotes: 1

Related Questions