I have the above code that is running and changes the mouse to load the icon and then when it succeeds, the other Anyway, it works perfectly on an example; However, when I click on two (or more) for example, it will leave the first instance with the loading icon, and then the icon for the last time will be changed twice.
I think that I understand what is happening and that my variables are over-written with new values, how can I decide? Should each instance of the function have its own set of variables? Right now I think variables (init_elem, closest_td, closest_tr) are global and therefore being overwritten?
"$ (this)" loses its context and hence the reason is that I am specifying it for the variable. I am using it on jqGrid and therefore it requires .on () because it does not work 'normally'. I have tried to use $ .proxy; But I have never used it before and I think it seems to work properly since the console. $ L_logging (this) Html () Anchor Showing HTML instead of HTML
$ (document) .ready (function () {$ ("# acquire-dialog"). Dialog ({autoOpen: false, modal: true});}); $ (Document) .on ('click', 'acquisition-confirmation', function (event) {event.preventDefault (); init_elem = $ (this); closest_td = $ (init_elem) .closest ("TD"); $ ("Option", "button", {"confirm", " : Function () {restore_html = $ (init_elem) .closest ("td") .html (); $ (closest_td) .html ('& lt; img class = "qmark" title = "Loading ... "Src =" Images / loading.gif "& gt; ';' $ .post ('In / _add_ajax.php', {section: 'Acquisition document', process_id: process_id}, function (data) {$ (" # Ajax_notifications "). Freew (data subject, data.message, {classes: [data.type]}); if (data. ($ '' Success') {$ (closest_tr). Search ("div: first") .removeClass ('(' Icon_status_0 ') .addClass (' icon_status_2 ') .attr (' title ',' You have access to this document (If the type of data. Stats! == "undefined") {var document_status = ['A', 'b', 'c']; $ (closest_p) .prev () .html (Document_status [data.status]); If (data.stats == 1) $ (closest_p) .html ('& lt; ac lass = "qmark" target = "_ blank" title = "Generate return for this document." Href = "/ generate_return Php? Id = '+ process_id +' "& gt; & lt; img src =" picture / icon_pdf contains png "limit =" 0 "/> I've tried to do it in relation to $ $. Proxy ():
$ Proxy ($ ("# acquire-dialog") dialog ("Open this); and
$ proxy. ($ (" # Acquire- Dialog "). Dialog (" open "), $ (this)); And in the end the event is also bound, although I think it's not right:
$ (document) .on ('click', '.acquire-confirmation', $ .proxy (function (event) {...}, this)); // and $ (this) < / Code>
You should use the var keyword otherwise your variable Will be overwritten You have JavaScript variable in javascript About the label can learn here
Comments
Post a Comment