2010-11-23 5 views
0

を仕事をしたい:ExtJSに、PHPはダブルクリックで動作し、私は行を持つテーブルがワンクリックで私のPHPコードで

name    actions 
category 1  edit 
category 2  edit 
.....    edit 

すべての編集ボタンは元のIDを持っている:<a href="edit('.$raw['id'].')" id="show-btn'.$raw['id'].'">

今、私の機能の編集は次のとおりです。

var win; 
var button; 


function edit(idd){ 

    button = Ext.get('show-btn'+idd); 

    button.on('click', function(){ 
     // create the window on the first click and reuse on subsequent clicks 
     if(!win){ 


      win = new Ext.Window({ 
       applyTo:'hello-win', 
       layout:'column', 

       closeAction:'hide', 
       plain: true, 
       autoHeight:true, 

       items: new Ext.FormPanel({ 
        applyTo: 'hello-tabs', 

       }), 

       buttons: [{ 
        text:'Modify', 
        handler: function(){ 

         win.hide(); 
         document.form_edit.submit(); 

        } 

        },{ 
         text: 'Close', 
         handler: function(){ 
          win.hide(); 
         } 
        }] 
       }); 
     } 
     win.show(this); 

    }); 
}; 

このスクリプトは私がワンクリックでこれを行うことができますどのように、安物の宝石クリックで完璧に動作しますが、。

私は今、問題はbutton.on('click')

多くのおかげであり、これで私を助けてください機能のいくつかのレベルが、その後のクリックに使用され、その後、あなたの最初のクリックしてで追加されているように思え

+0

ところで、私は$(document).ready(..効果が消えるので – cosy

+0

を使用したくありません)PHPとは何が関係していますか? http://dev.sencha.com/deploy/dev/docs/source/Button.html#event-Ext.Button-click)。 – Gordon

+0

今、私は何かを観察します。初めてダブルクリックすると動作します。最初のクリックで、なぜ最初のクリックではうまくいかないのですか? – cosy

答えて

2

を発行。 if(win)テストの前後に、アラートまたはconsole.log(ご使用のブラウザでサポートされている場合)のいずれかを編集機能内に置くことをお勧めします。

私も興味があります - これをテーブル全体に対して実行しようとしている場合、それはwinグローバル変数の問題を引き起こしますか?

function edit(idd){ 

    button = Ext.get('show-btn'+idd); 
    // this can be moved into button.on('click', function(){, but that may be 
    // causing the problem... 
    // come to think of it... the example here: 
    // http://dev.sencha.com/deploy/dev/examples/window/hello.js 
    // has this inside the button.on method. You may want to try it both ways. 
    if(!button.win){ 

     button.win = new Ext.Window({ 
      applyTo:'hello-win', 
      layout:'column', 

      closeAction:'hide', 
      plain: true, 
      autoHeight:true, 

      items: new Ext.FormPanel({ 
       applyTo: 'hello-tabs', 

      }), 

      buttons: [{ 
       text:'Modify', 
       handler: function(){ 

        win.hide(); 
        document.form_edit.submit(); 

       } 

       },{ 
        text: 'Close', 
        handler: function(){ 
         win.hide(); 
        } 
       }] 
      }); 
    } 
    button.on('click', function(){ 
     // the window already exists, so no need to worry about creating it. 
     button.win.show(this); 

    }); 
}; 

ことができると仕事:

は、私はあなたが事前に移入勝利をし、ローカル変数を使用した方がいいでしょうと思いますか?そうでない場合は、より多くのコードを参照する必要があります。

+0

私はそれを作りました。私はボタンを置き換えました。(クリック、機能(){ button.win.show(this); }); とwin.show(ボタン); – cosy

+0

これは完全に今、多くのおかげで動作します – cosy

関連する問題