There are some problems with writing code today. First of all, my HTML file is like this
<= "Tag_add" onclick= "AddUser ()"></Div >
NN, it is clear that the AddUser () method was called
varAddUser =function () { varI=0;Document.onkeydown=function(e) {varEV = document.all?window.event:e; if(ev.keycode==13) { Submit_dialog (); } if(ev.keycode==27) {Quit_dialog (); } } functionQuit_dialog () {
/* Hide Dialog div*/} $ ("#head_close, #bottom_canser"). Click (function() {quit_dialog (); }); functionSubmit_dialog () {Alert (Name+phone+Plantno); } $("#bottom_submit"). Click (function() {submit_dialog (); });}
First call, with the mouse point the submit, no problem; second call, eh? How did alert pop up two times?? Mother of the Egg! Third call, OK, alert pops up three times!
I immediately thought of the onclick call function is not every time you want to create a new function instance? Java EE has a single prototype concept, put in this case, it should be JS interpreter every time a new function object of a single case? This problem occurs when the previous singleton is not closed and then a singleton is called?? (here to solve AH!!) )
So I added a code to prove
varAddUser =function () { varI=0; Document.onkeydown=function(e) {varEV = document.all?window.event:e; if(ev.keycode==13) {submit_dialog (); } if(ev.keycode==27) {quit_dialog (); } } functionQuit_dialog () {/*hiding the dialog div .*/ } $("#head_close, #bottom_canser"). Click (function() {quit_dialog (); }); functionSubmit_dialog () {Alert (name+phone+Plantno); } $("#bottom_submit"). Click (function() {submit_dialog (); I++; Console.log (i); });}
And look at my control panel.
Yes, just like I thought! It is true that a new instance has been created. Just as I was sure this was the case, I found out that these problems won't happen with a button trigger! Is it because var addUser = function () {} is a prototype for every visit? Do not understand the solution Ah!
It is easy to think of the search for JS prototype How to use, prototype. I've heard a bit about it before and I forgot it for a long time ...
The problem has not been solved, if there is a master answer greatly appreciated Ah!