- //FormSpan contains a block of the form that is not being displayed. We will create clones of that and add them to tabs
- var form = $($("#formSpan").children()[0]).clone()
- var count = 0;
- //Each new tab will have the formId class attached to it. This way we can track how many forms we currently have out there and assign listeners to them
- if ($(".formId").length > 0) {
- var greatest = 0;
- var s = $(".formId");
- //for every recipe
- for (var i = 0; i < s.length; i++) {
- if (parseInt($(s[i]).attr("id").substring(6)) > greatest) {
- greatest = parseInt($(s[i]).attr("id").substring(6))
- }
- }
- count = greatest + 1;
- $("#properties_tab").append(
- ('<span class="formId" id="formId'+count+'"></span>'));
- } else {
- count++;
- $("#properties_tab").append(
- '<span class="formId" id="formId1"></span>');
- }
-
- //$(form).find("#policyName").val("Recipe "+makid(2))
- //TODO change up how we auto assign policyName. There could be the case where we do this and it will have repeats
- //alert($(form).find("#_id").val())
- //policyNameChangeListener(form)
- $("#add_one_more")
- .parent()
- .before(
- ' <li class="active"><a id="go_properties_tab'+count+'">Policy</a><button id="tab_close'+count+'" type="button" class="close tab-close-popup" aria-hidden="true" style="margin-top: -30px;margin-right: 5px">×</button></li>');
- $("#formId" + count).append(form);
- $(".formId").not($("#formId" + count)).css("display", "none")
- addCustListen(count)
- addTabListen(count)
- // This is for when the process is not loading from map but being created
- if(!loadingId){
- var l=makeid()
- $(form).find("#_id").val(l)
- policy_ids["#formId" + count]=l
- var answers={}
-
- for(var i=1;i<=greatestIdNum();i++){
- if($("#formId"+i).length>0){
-
- answers["#formId"+i+" #parentPolicy"]=$("#formId"+i+" #parentPolicy").val()
- $("#formId"+i+" #parentPolicy").empty();
- for(k in policy_ids){
- if($("#formId"+i+" #_id").val().toString()!==policy_ids[k] && $(k+" #recipe").val()!==undefined && $(k+" #recipe").val()!==""){
- $("#formId"+i+" #parentPolicy").append("<option value='"+policy_ids[k]+"''> "+$(k+" #recipe").val()+"</option>")
- }
- }
- $("#formId"+i+" #parentPolicy").prepend("<option value=''></option>")
- }
- }
- for(k in answers){
- $(k).val(answers[k])
- }
- }
-
-
-
- setMultiSelect();
- return defPolName;