load jquery function from a href onclick -


I have an HTML table with one HTML tag per line with the HTML code inside the tag:

< Pre> & lt; One onclick = "modalDialog (this); return false;" Href = "javascript: void (0)" & gt; 17,795 & lt; / A & gt; & Lt; Div style = "display: none;" Class = "MessageDataDiv" & gt; Some text to show in my jquery modal window when the function is clicked on modaldialog & Lt; / Div & gt;

and jquery functions that are moved onclick in a href link

  function modalDialog (event) {$ ('a.message') . ). Click (function () {var div = new $ (this) .closest ("td"). Find (". MessageDataDiv") clone (); div.show (). Dialog (); event.preventDefault ();}); }  

Can someone help me with some advice on how to write the jquery function even more accurately so that the function is set to fire only once when the link is clicked on. I need the jQuery function modalDialog as a separate function because the HTML table uses Ajax partial rendering ...

The problem is that when I click on a href link for the first time anything The second click on the link gives two modal dialogs and with the third click, I get three modal dialogs and so on ...

I think the easiest way is to find a second div that A second div.

  & lt; Div id = "messageDataDiv" & gt; & Lt; / Div & gt; & Lt; Script & gt; $ (Function () {$ ('# messageDataDivove') dialog ({autoOpen: false});}); Function modalDialog (A) {if ($ (A). Data ('click')) return false; $ (A). Data ('clicked' is true); . $ ('# MessageDataDiv') HTML ($ (a) .next () text ().) Dialog () .; return false; } & Lt; / Script & gt;  

This way you do not have to open the dialog every time.


Comments