-2

この次のコードでは、目的の出力を取得しています

fn: function(btn) {
switch(btn){
case 'yes':
Ext.Msg.prompt('Milton', 'Where is it?');
break;
case 'no':
Ext.Msg.alert('Milton',
'Im going to burn the building down!');
break;
case 'cancel':
Ext.Msg.wait('Saving tables to disk...','File Copy');
break;
}
}

これは問題なく動作します。今、スイッチ「はい」で関数呼び出しを実行しようとしていますが、画面に何も出力されません。
これは私が使用しているコードです。

case 'yes':
Ext.Msg.prompt('Milton', 'Where is it?', function(btn,txt)
{
if (txt.toLowerCase() == 'the office') {
Ext.get('my_id').dom.innerHTML = 'Dull Work';
}else{
Ext.get('my_id').dom.innerHTML = txt;
}
Ext.DomHelper.applyStyles('my_id',{
background: 'transparent
url(images/stapler.png) 50% 50% no-repeat'
});
});
break;

このコードをスイッチ ケース 'yes' 内で使用すると、空白の画面が表示されます。ダイアログボックスも消えました。助けてください。

4

1 に答える 1

0

これは非常に基本的な JavaScript エラーです。文字列は、行末を超えることはできません。これは機能します。

case 'yes':
Ext.Msg.prompt('Milton', 'Where is it?', function(btn,txt){
    if (txt.toLowerCase() == 'the office') {
        Ext.get('my_id').dom.innerHTML = 'Dull Work';
    }else{
        Ext.get('my_id').dom.innerHTML = txt;
    }
    Ext.DomHelper.applyStyles('my_id',{
        background: 'transparent url(images/stapler.png) 50% 50% no-repeat'
    });
});
break;

コンソールでエラーが発生しましたSyntaxError: Unexpected token ILLEGAL

于 2013-10-11T09:46:02.313 に答える