浏览代码

Fixed a regression: autocomplete not working due to a change in the execution of the script rendered in Ajax

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@168 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 年之前
父节点
当前提交
5942f55273
共有 3 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      application/cmdbabstract.class.inc.php
  2. 1 1
      js/wizardhelper.js
  3. 1 1
      pages/ajax.render.php

+ 2 - 2
application/cmdbabstract.class.inc.php

@@ -645,13 +645,13 @@ abstract class cmdbAbstractObject extends CMDBObject
 						//Enum field or external key, display a combo
 						if (count($aAllowedValues) == 0)
 						{
-							$sHTMLValue = "<input type=\"text\" size=\"30\" value=\"\" name=\"attr_{$sAttCode}{$sNameSuffix}\" id=\"$iInputId\"{$sCSSClasses}/>";
+							$sHTMLValue = "<input count=\"0\" type=\"text\" size=\"30\" value=\"\" name=\"attr_{$sAttCode}{$sNameSuffix}\" id=\"$iInputId\"{$sCSSClasses}/>";
 						}
 						else if (count($aAllowedValues) > 50)
 						{
 							// too many choices, use an autocomplete
 							// The input for the auto complete
-							$sHTMLValue = "<input type=\"text\" id=\"label_$iInputId\" size=\"30\" name=\"\" value=\"$sDisplayValue\"{$sCSSClasses}/>";
+							$sHTMLValue = "<input count=\"".count($aAllowedValues)."\" type=\"text\" id=\"label_$iInputId\" size=\"30\" name=\"\" value=\"$sDisplayValue\"{$sCSSClasses}/>";
 							// another hidden input to store & pass the object's Id
 							$sHTMLValue .= "<input type=\"hidden\" id=\"$iInputId\" name=\"attr_{$sAttCode}{$sNameSuffix}\" value=\"$value\" />\n";
 							$oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});");

+ 1 - 1
js/wizardhelper.js

@@ -108,7 +108,7 @@ function WizardHelper(sClass)
 				$('body').append(html);
 				//console.log('data received:', oWizardHelper);
 				//oWizardHelper.FromJSON(json_data);
-				oWizardHelper.UpdateFields();
+				//oWizardHelper.UpdateFields(); // Is done directly in the html provided by ajax.render.php
 				//console.log(oWizardHelper);
 				$('#wizStep'+ G_iCurrentStep).unblock( {fadeOut: 0} );
 			});

+ 1 - 1
pages/ajax.render.php

@@ -94,7 +94,7 @@ switch($operation)
 
 		$oWizardHelper->SetAllowedValuesHtml($sAttCode, $sHTMLValue);
 	}
-	$oPage->add("<script type=\"text/javascript\">\noWizardHelper.m_oData=".$oWizardHelper->ToJSON().";\n</script>\n");
+	$oPage->add("<script type=\"text/javascript\">\noWizardHelper.m_oData=".$oWizardHelper->ToJSON().";\noWizardHelper.UpdateFields();\n</script>\n");
 	break;
 		
 	case 'ajax':