Explorar o código

Use the latest version (unmodified) of autocomplete instead of an old - and customized - version.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@126 a333f486-631f-4898-b8df-5754b55c2be0
dflaven %!s(int64=15) %!d(string=hai) anos
pai
achega
f7b9c27ad7
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      application/ui.linkswidget.class.inc.php

+ 4 - 3
application/ui.linkswidget.class.inc.php

@@ -51,9 +51,9 @@ class UILinksWidget
 		{
 		{
 			// Serialize the link set into a JSon object
 			// Serialize the link set into a JSon object
 			$aCurrentValues = array();
 			$aCurrentValues = array();
-			$sRow = '{';
 			while($oLinkObj = $oCurrentValuesSet->Fetch())
 			while($oLinkObj = $oCurrentValuesSet->Fetch())
 			{
 			{
+				$sRow = '{';
 				foreach($aAttributes as $sLinkAttCode)
 				foreach($aAttributes as $sLinkAttCode)
 				{
 				{
 					$sRow.= "\"$sLinkAttCode\": \"".addslashes($oLinkObj->Get($sLinkAttCode))."\", ";
 					$sRow.= "\"$sLinkAttCode\": \"".addslashes($oLinkObj->Get($sLinkAttCode))."\", ";
@@ -70,7 +70,7 @@ class UILinksWidget
 			// too many choices, use an autocomplete
 			// too many choices, use an autocomplete
 			// The input for the auto complete
 			// The input for the auto complete
 			$sTitle = $oAttDef->GetDescription();
 			$sTitle = $oAttDef->GetDescription();
-			$sHTMLValue .= "<script>\n";
+			$sHTMLValue .= "<script type=\"text/javascript\">\n";
 			$sHTMLValue .= "oLinkWidget{$this->m_iInputId} = new LinksWidget('{$this->m_iInputId}', '$sLinkedClass', '$sExtKeyToMe', '$sExtKeyToRemote', $sAttributes);\n";
 			$sHTMLValue .= "oLinkWidget{$this->m_iInputId} = new LinksWidget('{$this->m_iInputId}', '$sLinkedClass', '$sExtKeyToMe', '$sExtKeyToRemote', $sAttributes);\n";
 			$sHTMLValue .= "</script>\n";
 			$sHTMLValue .= "</script>\n";
 			$sHTMLValue .= $this->GetObjectPickerDialog($oPage, $sTargetClass, 'oLinkWidget'.$this->m_iInputId.'.OnOk');
 			$sHTMLValue .= $this->GetObjectPickerDialog($oPage, $sTargetClass, 'oLinkWidget'.$this->m_iInputId.'.OnOk');
@@ -81,7 +81,8 @@ class UILinksWidget
 			// another hidden input to store & pass the object's Id
 			// another hidden input to store & pass the object's Id
 			$sHTMLValue .= "<input type=\"hidden\" id=\"id_ac_{$this->m_iInputId}\"/>\n";
 			$sHTMLValue .= "<input type=\"hidden\" id=\"id_ac_{$this->m_iInputId}\"/>\n";
 			$sHTMLValue .= "<input type=\"hidden\" id=\"{$this->m_iInputId}\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"/>\n";
 			$sHTMLValue .= "<input type=\"hidden\" id=\"{$this->m_iInputId}\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"/>\n";
-			$oPage->add_ready_script("\$('#{$this->m_iInputId}').val('$sJSON');\n\$('#ac_{$this->m_iInputId}').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#id_ac_{$this->m_iInputId}', extraParams:{operation:'ui.linkswidget', sclass:'{$this->m_sClass}', attCode:'{$this->m_sAttCode}', max:30}});");
+			$oPage->add_ready_script("\$('#{$this->m_iInputId}').val('$sJSON');\noLinkWidget{$this->m_iInputId}.Init();\n\$('#ac_{$this->m_iInputId}').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#id_ac_{$this->m_iInputId}', extraParams:{operation:'ui.linkswidget', sclass:'{$this->m_sClass}', attCode:'{$this->m_sAttCode}', max:30}});");
+			$oPage->add_ready_script("\$('#ac_{$this->m_iInputId}').result( function(event, data, formatted) { if (data) { $('#id_ac_{$this->m_iInputId}').val(data[1]); } } );");
 		}
 		}
 		else
 		else
 		{
 		{