2013-07-10 11 views
2

我想的是,我有一個像如何調用上點擊功能合金UI與相同的CSS類名的所有元素

<a href="javascript:void(0)" class="popup-link">sample Link 1</a> <a href="javascript:void(0)" class="popup-link">sample Link 2</a> 

幾個環節,我想,當用戶點擊鏈接調用靜態HTML。對於我已經寫了代碼

AUI().ready(
'aui-aria', 
    'aui-dialog', 
    'aui-overlay-manager', 
    'dd-constrain', 
    function(A) { 
    A.all('.popup-link').on('click', 
     function() { 
     var dialog = new A.Dialog({ 
       bodyContent: 'Loading...', 
       centered: true, 
       title: 'Sample Popup Content', 
       width: 400, 
       height:600 
      } 
     ).render(); 

      dialog.plug(
      A.Plugin.IO, 
      { 
       autoLoad: false, 
       uri: '/html/sample.html' 
      } 
     ); 

      dialog.io.start(); 
     }); 
    }); 

,但是,這並不工作,它根本不會調用函數時,我點擊鏈接,我也嘗試過這一點,但同樣的事情

AUI().ready(
    'aui-aria', 
    'aui-dialog', 
    'aui-overlay-manager', 
    'dd-constrain', 
    function(A) { 
    A.all('.sample-popup').each(function() { 
     this.on('click', function(A){ 
      ..... 
      ...... 

任何想法這裏有什麼問題?

+0

菲利克斯,你運行的是什麼版本的合金? – jbalsas

+0

我使用LR 6.1.20 EE,因此它必須是Alloy UI 1.5。 –

回答

0

我不知道很多關於AUI但如果你想使用來實現相同的任務jQuery的就可以實現這樣的

<script> 
$(document).ready(function() { 

    $('.popup-link').click(function(){ 
     alert($(this).text()); 
    }); 

}); 
</script> 

或者

使用Javascript

<a href="#" onclick="return theFunction();">Link</a> 

<script type="text/javascript"> 
    function theFunction() { 
     // return true or false, depending on whether you want to allow the `href` property to follow through or not 
    } 
</script> 

HTH

+0

這是完美的,但我正在尋找合金用戶界面,因爲這是一個棘手的,不工作! –

4

最後我得到了它爲什麼不工作。我在點擊功能中也使用了相同的對象「A」。

它應該是這樣的:(看看變量名稱事件)

AUI().ready(
    'aui-aria', 
    'aui-dialog', 
    'aui-overlay-manager', 
    'dd-constrain', 
    function(A) { 
    A.all('.sample-popup').each(function() { 
     this.on('click', function(event){ 
      ..... 
      ...... 
相關問題