tags:

views:

31

answers:

2

Hello,

I have a jquery plugin X and inside the plugin I have a function test();

My problem is how to call the function test in plugin X from my document..

 $("#abc").html('<a href="jQuery.X.test()">test</a>');

But it doesn't work. Is there a simple solution?

Thank you for your time.

A: 

I seem to remember it would be jQuery.test(), not jQuery.X.test()

Here Be Wolves
it says "is not a function"
Alec Smart
could you post some of your plugin code? I understand that its a custom build plugin, is that right?
Here Be Wolves
+1  A: 

You shouldn't set href to JavaScript (you could if you prefix it with javascript: but don't.) You can do something like this instead:

$('#abc').html('<a href="#">test</a>').find('a').click(jQuery.X.test);

What it does:

  • Get the #abc element
  • Set its HTML to an anchor element
  • Select the anchor element
  • Attach a click event to the anchor element
Blixt