jquery - Getting uidialog full contents -


i have uidialog , full content of it, reason getting old html contents if use .html(), current live contents if use serialize.

so, inside dialog have:

alert($(this).find('form').serialize()); //this serializes current live contents, appear in uidialog form. alert($(this).html()); //this shows html before modifications on dialog 

why html() shows html before modifications, while serialize() shows me serialization current values inputted?

you cannot obtain html(). created function takes serialized array , populates container save dialog html. how called dialog:

//set current vals html before saving setinputvals('#' + $(this).attr('id'), $(this).find('input, select, textarea').serializearray()); 

and function:

/*  * sets input vals container  *   * @param container_id id of container  * @param inputvals serialized array used set values  *   * @return boolean. modifies container  */ function setinputvals(container_id, inputvals) {     //order name     var inputvalsbyname = new array();     $.each(inputvals, function(key, value) {        inputvalsbyname[value.name] = value.value;     });      //loop through inputs , set correct values     $.each($(container_id + " :input"), function(key, value) {         if (!value.name in inputvalsbyname) {             return true;         }          //loop through each type. make sure add new types here when needed. notice val() won't work         //for changing html, , why attributes used.         if (value.type == 'radio') {             //remove checked attribute , add correct 1             $('input:radio[name=' + value.name + ']').removeattr('checked');             $('input:radio[name=' + value.name + ']').filter('[value="' + inputvalsbyname[value.name] + '"]').attr('checked', 'checked');           } else if (value.type == 'checkbox') {             //checked attribute checkbox             if (inputvalsbyname[value.name] != undefined) {                 $(this).attr('checked', 'checked');             } else {                 $(this).removeattr('checked');             }         } else if (value.type == 'textarea') {             //set text textarea             $(this).text(inputvalsbyname[value.name]);         } else if (value.type == 'select-one') {             //remove selected attribue options , add correct one.             $(this).find('option').removeattr('selected');             $(this).find('option[value="' + inputvalsbyname[value.name] + '"]').attr('selected', 'selected');         } else if (value.type == 'text') {             //set value attribute text input             $(this).attr('value', inputvalsbyname[value.name]);         }      });       return true; }  

tested on major browsers. hope helps someone! :)


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -