Explorar o código

fixed Typespecial export parm for textarea

Piotr Labudda %!s(int64=8) %!d(string=hai) anos
pai
achega
5dbae66d64
Modificáronse 1 ficheiros con 12 adicións e 10 borrados
  1. 12 10
      SE/se-lib/Typespecial.php

+ 12 - 10
SE/se-lib/Typespecial.php

@@ -792,7 +792,7 @@ jQuery('#typeahead-{$fName}').typeahead({
 				'</div>';
 			},
 			option: function(item, escape) {
-//console.log('--- render.option item(',item,') this:',this);
+				// console.log('--- render.option item(',item,') this:',this);
 				return '<div>' +
 					'<span class=\"title\">' +
 						escape(item.name || item.id) +
@@ -802,12 +802,12 @@ jQuery('#typeahead-{$fName}').typeahead({
 		},
 		onItemAdd: function(value, item) {// Invoked when an item is selected.
 			var curSel = this.options[value] || null, fieldExport;
-//console.log('--- onItemAdd val(',value,'/',item.data('name'),'/',item,') this:curSel:',curSel);
+			// console.log('--- onItemAdd val(',value,'/',item.data('name'),'/',item,') this:curSel:',curSel);
 			if (curSel && curSel.exports) {
 				for (var i in curSel.exports) {
 					fieldExport = jQuery('#ts-f' + i);
 					if (fieldExport.length) {
-//console.log('--- onItemAdd fieldExport.selectize(',fieldExport.selectize,')', fieldExport);
+						// console.log('--- onItemAdd fieldExport.selectize(',fieldExport.selectize,')', fieldExport);
 						if (fieldExport.get(0).selectize) {
 							fieldExport.get(0).selectize.addOption({id:curSel.exports[i], name:curSel.exports[i]});
 							fieldExport.get(0).selectize.setValue(curSel.exports[i]);
@@ -815,12 +815,14 @@ jQuery('#typeahead-{$fName}').typeahead({
 							//jQuery('#f' + i).val(curSel.exports[i]);
 						}
 					} else {
-//console.log('--- onItemAdd jQuery(#f' + i + ').val(', curSel.exports[i], '): fieldExport.is(input:',fieldExport.is('input'),'/select:',fieldExport.is('select'),')', fieldExport);
-						fieldExport = jQuery('#f' + i);
-						if (fieldExport.is('input')) {
-							jQuery('#f' + i).val(curSel.exports[i]);
-						} else if (fieldExport.is('select')) {
-							//TODO: add option and select //jQuery('#f' + i).val(curSel.exports[i]);
+						var fldExportNode = document.getElementById('f' + i)
+						if (fldExportNode) {
+							console.log('--- onItemAdd jQuery(#f' + i + ').val(', curSel.exports[i], '): fieldExport.is(input:',fieldExport.is('input'),'select:',fieldExport.is('select'),'textarea:',fieldExport.is('textarea'),')', fieldExport);
+							switch (fldExportNode.tagName) {
+								case 'INPUT': jQuery('#f' + i).val(curSel.exports[i]); break;
+								case 'SELECT': /* TODO: add option and select //jQuery('#f' + i).val(curSel.exports[i]); */; break;
+								case 'TEXTAREA': jQuery('#f' + i).val(curSel.exports[i]); break;
+							}
 						}
 					}
 				}
@@ -848,7 +850,7 @@ jQuery('#typeahead-{$fName}').typeahead({
 			};
 		},
 		load: function(query, callback) {
-			//if (!query.length) return callback();
+			// if (!query.length) return callback();
 			$.ajax({
 				url: '{$ajaxDataUrlBase}',
 				data: 'q=' + encodeURIComponent(query),