Commit 92042ebb authored by Jos Schellevis's avatar Jos Schellevis

style fixes in javascript

parent 4d00208b
...@@ -8,12 +8,12 @@ function getFormData(parent) { ...@@ -8,12 +8,12 @@ function getFormData(parent) {
data = {}; data = {};
$( "#"+parent+" input,#"+parent+" select" ).each(function( index ) { $( "#"+parent+" input,#"+parent+" select" ).each(function( index ) {
if ($(this).attr('id') == undefined) { if ($(this).prop('id') == undefined) {
// we need an id. // we need an id.
return; return;
} }
node = data ; node = data ;
keyparts = $(this).attr('id').split('.'); keyparts = $(this).prop('id').split('.');
for (var i in keyparts) { for (var i in keyparts) {
if (!(keyparts[i] in node)) { if (!(keyparts[i] in node)) {
node[keyparts[i]] = {}; node[keyparts[i]] = {};
...@@ -25,7 +25,9 @@ function getFormData(parent) { ...@@ -25,7 +25,9 @@ function getFormData(parent) {
// selectbox, collect selected items // selectbox, collect selected items
var tmp_str = ""; var tmp_str = "";
$(this).children().each(function(index){ $(this).children().each(function(index){
if ($(this).prop("selected")){ // normally this should use prop, but this sometimes seem to return incorrect data....
// maybe replace this with a later version of jquery. tested with 1.11.2
if ($(this).attr("selected") != undefined){
if (tmp_str != "") tmp_str = tmp_str + ","; if (tmp_str != "") tmp_str = tmp_str + ",";
tmp_str = tmp_str + $(this).val(); tmp_str = tmp_str + $(this).val();
} }
...@@ -63,12 +65,12 @@ function getFormData(parent) { ...@@ -63,12 +65,12 @@ function getFormData(parent) {
*/ */
function setFormData(parent,data) { function setFormData(parent,data) {
$( "#"+parent+" input,#"+parent+" select" ).each(function( index ) { $( "#"+parent+" input,#"+parent+" select" ).each(function( index ) {
if ($(this).attr('id') == undefined) { if ($(this).prop('id') == undefined) {
// we need an id. // we need an id.
return; return;
} }
node = data ; node = data ;
keyparts = $(this).attr('id').split('.'); keyparts = $(this).prop('id').split('.');
for (var i in keyparts) { for (var i in keyparts) {
if (!(keyparts[i] in node)) { if (!(keyparts[i] in node)) {
break; break;
...@@ -111,12 +113,12 @@ function setFormData(parent,data) { ...@@ -111,12 +113,12 @@ function setFormData(parent,data) {
*/ */
function handleFormValidation(parent,validationErrors) { function handleFormValidation(parent,validationErrors) {
$( "#"+parent+" input" ).each(function( index ) { $( "#"+parent+" input" ).each(function( index ) {
if (validationErrors != undefined && $(this).attr('id') in validationErrors) { if (validationErrors != undefined && $(this).prop('id') in validationErrors) {
$("*[for='" + $(this).attr('id') + "']").addClass("has-error"); $("*[for='" + $(this).prop('id') + "']").addClass("has-error");
$("span[for='" + $(this).attr('id') + "']").text(validationErrors[$(this).attr('id')]); $("span[for='" + $(this).prop('id') + "']").text(validationErrors[$(this).prop('id')]);
} else { } else {
$("*[for='" + $(this).attr('id') + "']").removeClass("has-error"); $("*[for='" + $(this).prop('id') + "']").removeClass("has-error");
$("span[for='" + $(this).attr('id') + "']").text(""); $("span[for='" + $(this).prop('id') + "']").text("");
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment