この例は extJs で見つけました。スライドが発生するために Ext.example.msg を使用していることがわかります。そのため、example.js ファイルを 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();
}
}
};
}();
index.html に path を追加しました<script src="./example/example.js" type="text/javascript" ></script>
。example.js 内にデバッガーを保持しています。この ( ) 行で失敗し、Uncaught TypeError: Cannot call method 'apply' of undefinedvar s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
というメッセージが表示されます。これは何についてですか?コントローラーに保存ボタンがあり、
Ext.MessageBox.alert('Save', 'xxxx', showResult);
function showResult(btn){
debugger;
Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
};
ExtJs 4.2 の新しい方法論は何ですか。提案してください。