developer.jelix.org is not used any more and exists only for
history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Ticket #1141: dynamixFillAjax_synchrone.diff
File dynamixFillAjax_synchrone.diff, 3.9 KB (added by Litchi, 11 years ago) |
---|
-
lib/jelix-www/js/jforms_jquery.js
diff -r 0dccd5389dc5 lib/jelix-www/js/jforms_jquery.js
a b 108 108 if(elt.getAttribute('type') == 'checkbox') 109 109 return elt.checked; 110 110 case "textarea": 111 var val = jQuery.trim(elt.value); 111 var val = jQuery.trim(elt.value); 112 112 return (val !== '' ? val:null); 113 113 case "select": 114 114 if (!elt.multiple) … … 118 118 if (elt.options[i].selected) 119 119 values.push(elt.options[i].value); 120 120 } 121 if(values.length) 122 return values; 121 if(values.length) 122 return values; 123 123 return null; 124 124 } 125 125 } else if(this.isCollection(elt)){ … … 133 133 if(values.length) { 134 134 if (elt[0].getAttribute('type') == 'radio') 135 135 return values[0]; 136 return values; 136 return values; 137 137 } 138 138 } 139 139 return null; … … 187 187 isCollection: function(elt) { 188 188 if (typeof HTMLCollection != "undefined" && elt instanceof HTMLCollection) { 189 189 return true; 190 } 190 } 191 191 if (typeof NodeList != "undefined" && elt instanceof NodeList) { 192 192 return true; 193 193 } … … 273 273 274 274 var elt = this.element.elements[ctrl.name]; 275 275 276 jQuery.post(jFormsJQ.selectFillUrl, param, 277 function(data){ 278 if (typeof data.data == "undefined") 276 jQuery.ajax({ 277 type : 'POST', 278 url : jFormsJQ.selectFillUrl, 279 data : param, 280 dataType : 'json', 281 async : false, 282 success : function(data){ 283 if (typeof data.data == "undefined") 279 284 return; 280 285 if(elt.nodeType && elt.nodeName.toLowerCase() == 'select') { 281 var emptyitem = jQuery('option[value=""]', elt); 282 jQuery(elt).empty(); 286 var emptyitem = jQuery('option[value=""]', elt); 287 jQuery(elt).empty(); 283 288 var opt; 284 289 if (0 < emptyitem.length) { 285 290 opt = document.createElement('option'); … … 295 300 elt.appendChild(opt); 296 301 } 297 302 } 298 }, "json"); 303 } 304 }); 299 305 } 300 306 }; 301 307 … … 480 486 }; 481 487 jFormsJQControlDatetime.prototype.getValue = function(){ 482 488 if (!this.multiFields) { 483 var val = jQuery.trim(jQuery('#'+this.formName+'_'+this.name).val()); 484 return (val!==''?val:null); 489 var val = jQuery.trim(jQuery('#'+this.formName+'_'+this.name).val()); 490 return (val!==''?val:null); 485 491 } 486 492 487 493 var controlId = '#'+this.formName+'_'+this.name; … … 530 536 }; 531 537 jFormsJQControlDate.prototype.getValue = function(){ 532 538 if (!this.multiFields) { 533 var val = jQuery.trim(jQuery('#'+this.formName+'_'+this.name).val()); 534 return (val!==''?val:null); 539 var val = jQuery.trim(jQuery('#'+this.formName+'_'+this.name).val()); 540 return (val!==''?val:null); 535 541 } 536 542 537 543 var controlId = '#'+this.formName+'_'+this.name; … … 806 812 } 807 813 var name = control.name.replace(/\[\]/, ''); 808 814 jQuery("#"+this.form.name+"_"+name+"_label").addClass('jforms-error'); 809 815 810 816 if(messageType == 1){ 811 817 this.message += '<li class="error"> '+control.errRequired + "</li>"; 812 818 }else if(messageType == 2){ … … 833 839 jQuery(ul).hide(); 834 840 } 835 841 } 836 }; 837 No newline at end of file 842 };