2011-01-27 75 views
0

我有ZeroClipBoard下面的JS代碼:關閉不工作

onComplete: function(item) { 

      var text= $(item).html();//Not working when I hover the clip 
      //var text= 'Hello';// This is working when I hover the clip 

      var clip = new ZeroClipboard.Client(); 
      clip.setHandCursor(true); 

      clip.addEventListener('complete', function(client, text) { 
       debugstr("Copied text to clipboard: " + text); 
      }); 

      clip.addEventListener('mouseOver', function(client) { 
       clip.setText(text); 
      }) 

      // glue specifying our button AND its container 
      clip.glue('id_clip_button', 'id_clip_container'); 

     }, 

以上的onComplete是被稱爲上的一些動作oneofmy功能。我從它得到的項目是html元素。 現在在上面的代碼:

 var text= $(item).html();//Not working when I hover the clip 
     //var text= 'Hello';// This is working when I hover the clip 

如果我評論的第一行,並取消對剪輯工作和文字是越來越被複制到剪貼板中的第二條線。但是我必須在複製文本時使用該html元素的值。那麼我應該怎麼去呢?我得到控制的價值在這一點上

變種文字= $(項目)的.html(); //

但是當懸停函數被調用它丟失。我在想它會通過Closure保存下來。我錯過了什麼嗎?我不能在這行獲得的文本值:

clip.setText(text); 
+0

我的回答你能告訴我們什麼`的console.log(項目)`給?並且,`console.log($(item).length)`。 – 2011-01-27 12:41:05

回答