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

SVN:trunk[168]
This commit is contained in:
Romain Quetiez
2009-09-16 15:00:40 +00:00
parent 6964ca3003
commit 5efd4f10f5
3 changed files with 4 additions and 4 deletions

View File

@@ -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."'}});");

View File

@@ -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} );
});

View File

@@ -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':