2011-08-11 116 views
0

我有这个NyroModal:NyroModal不工作添加链接与jQuery

$('.openModal').nyroModal(); 

然后,我有我的链接:

<a href="#sample" class="openModal">this is a test</a> 

这个伟大的工程,它加载我的样态像它应该,但是当我使用添加一个链接

$("#mydiv").html('<a href="#sample" class="openModal">this is a test</a>'); 

它不工作,我已经试过这

$('.openModal a').live('click',function(e) { 
     e.preventDefault(); 
     $(this).nyroModalManual(); 
     return false; 
}); 

这:

$('.openModal a').live('click',function(e) { 
     e.preventDefault(); 
     $(this).nmManual("#sample"); 
     return false; 
    }); 

但我没有任何运气,你能想到的任何东西我可以试试吗?我究竟做错了什么?

谢谢!

更新:我忘了提,我没有得到任何错误都在我的控制台

更新2:现在我得到这个错误,现在我正确选择它:

Uncaught TypeError: Object [object Object] has no method 'nyroModalManual'

回答

1

他呢?

$('.openModal a').live('click',function(e) { 
     e.preventDefault(); 
     $.nmManual("#sample"); 
    }); 

或我想这个选择你有:

$('a.openModal').live('click',function(e) { 
     e.preventDefault(); 
     $.nmManual("#sample"); 
    }); 
1

外观就像你想将a.openModal作为你的选择器一样。目前,它使用openModal类来选择某个元素。 你可能想要看看委托,而不是现在的首选iirc。

我看到您的更新。你不应该用nyroModal来调用它,而不是nyroModalManual? nm手册看起来也可能是有效的。

+0

嗨corn_dog,谢谢您的回复,我已经尝试过了,它似乎的确,我没有选择正确的元素。但是,我现在收到一个错误,我更新了我的问题和它的意思。再次感谢 –