javascript - Recursion is not working properly and getting out of function without executing definition? -


i have function named check_reviewed(form) , have div confirm box. showing , hiding in function , calling function again. on call, goes last parenthesis of function , doesn't execute complete function(as shown debugger , experienced). unable understand behaviour.

the code snippet below:

in html file have div id createdconfirmbox display hidden.

the js functions:

function hidebox(boxname){     $("#"+boxname).hide();     $("bl").hide(); } function createconfirmbox(name){     var confirmbox = $("#createdconfirmbox");     var content = "<div   id='cross_createdconfirmbox_"+name+"' class='cross'>x</div><span id='spancreatedconfirmbox_"+name+"' style='text-align:center; font-size:18px; line-height:25px; width:580px; padding:7px; font-style:italic; background-color:white; display:inline-block; border-radius:10px;'></span><br><br><div style='text-align:center;' id='divcreatedconfirmbox_"+name+"'></div><br><div style='text-align:center;'><button class='btn btn-primary' type='button'   id='btn_createdconfirmbox_yes_"+name+"' style='padding:5px 25px; margin-right:40px; font-size:18px;' >yes</button><button class='btn btn-cancel' type='button'   style=' padding:5px 25px; font-size:18px; margin-left:40px;' id='btn_createdconfirmbox_no_"+name+"'>no</button></div><br>";     confirmbox.html(content); }  function check_review(form){ ... ... ... var company_new = $("#company").val().trim();         if(company_old && company_old!="" && company_new==""){             createconfirmbox("company");             $("#createdconfirmbox").attr("box-made-for","company");             $("#spancreatedconfirmbox_company").html("<label style='color:red;'><b>warning!!!</b></label><br>you have removed <b>company name</b> contact details.<br><br><span style='padding:7px;display:inline-block;'>existing company name: <b>"+company_old+"</b><br>new company name: <label style='color:#c8c8c8;'>removed<label></span>");             $("#divcreatedconfirmbox_company").html("<label  style='color:#464444;'>do want continue without <b>company name?</b></label>");             $("#btn_createdconfirmbox_yes_company").on('click',function(){                 company_old="";                 $("#company").val("");                 hidebox("createdconfirmbox");                  check_reviewed(form);             });             $("#btn_createdconfirmbox_no_company").on('click',function(){                 $("#company").val(company_old);                 hidebox("createdconfirmbox");                  check_reviewed(form);             });             $("#cross_createdconfirmbox_company").on('click',function(){                 $("#company").val(company_old);                 hidebox("createdconfirmbox");                  check_reviewed(form);             });             $("#createdconfirmbox").show();             $("#bl").show();             return true;         }     } 

so said on click of button btn_createdconfirmbox_no_company goes function defined on click of it. when comes line check_reviewed(form); goes last line of function } without executing code in it. yhen goes last line of click function }); , exit.

i unable understand behaviour.

if have other method can work explain want call function check_reviewd(form); on click of button without making form global variable.

actually, problem in code written above in function. it's getting outside function using return false. used breakpoints reach this. reason was making checkbox disable on success of ajax request fired whenever city name changes , due disable checkbox, getting out of function before completing it.

i know silly mistake , lack of knowledge. thank you, everyone, responses , valuable time.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -