From version < 51.9 >
edited by Eduard Moraru
on 2014/11/01
To version < 52.1 >
edited by Buzila Vlad
on 2016/04/21
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.enygma
1 +XWiki.BuzilaVlad
Content
... ... @@ -136,29 +136,29 @@
136 136  
137 137  {{code}}
138 138  (function(){
139 - document.observe('dom:loaded', function () {
140 - myForm = document.getElementById('inline').elements;
141 - for(i=0; i<myForm.length; i++){
142 - if(myForm[i].id =='Supplier'){
143 - mySuggest(myForm[i], 'Suppliers');
144 - }
145 - if(myForm[i].id=='Product'){
146 - mySuggest(myForm[i], 'Products');
147 - }
148 - }
149 - }); // end of doc observe
139 + document.observe('dom:loaded', function () {
140 + myForm = document.getElementById('inline').elements;
141 + for(i=0; i<myForm.length; i++){
142 + if(myForm[i].id =='Supplier'){
143 + mySuggest(myForm[i], 'Suppliers');
144 + }
145 + if(myForm[i].id=='Product'){
146 + mySuggest(myForm[i], 'Products');
147 + }
148 + }
149 + }); // end of doc observe
150 150  })();
151 151  
152 152  function mySuggest(element, space) {
153 - if (!element.suggest) {
154 - element.suggest = new XWiki.widgets.Suggest(element, {
155 - script: "$xwiki.getURL('Sandbox.AutoSuggest', 'get', 'outputSyntax=plain&spacename=')"+space+"&",
156 - varname: "input",
157 - seps: " ,|",
158 - offsety: 13,
159 - minchars: 1
160 - });
161 - }
153 + if (!element.suggest) {
154 + element.suggest = new XWiki.widgets.Suggest(element, {
155 + script: "$xwiki.getURL('Sandbox.AutoSuggest', 'get', 'outputSyntax=plain&spacename=')"+space+"&",
156 + varname: "input",
157 + seps: " ,|",
158 + offsety: 13,
159 + minchars: 1
160 + });
161 + }
162 162  }
163 163  {{/code}}
164 164  
... ... @@ -205,6 +205,35 @@
205 205  })();
206 206  {{/code}}
207 207  
208 +== Search suggest shows document title but searches by document name ==
209 +
210 +Example:
211 +
212 +The request
213 +
214 +{{code}}
215 +
216 +#set($suggestURL = $xwiki.getURL('Main.WebHome', 'view', "&xpage=suggest&classname=SomeSpace.SomeClass&fieldname=entity&firCol=obj.name&secCol=doc.title"))
217 +
218 +onfocus='new XWiki.widgets.Suggest(this, {script:"$escapetool.javascript("${suggestURL}&")", varname:"input", callback: function(obj) {resource.onChangeEntity(obj.info, obj.value);}} )'
219 +
220 +{{/code}}
221 +
222 +The JavascriptExtension object
223 +
224 +{{code}}
225 +
226 +// entityValue is the document name and entityInfo is the document title
227 + onChangeEntity: function(entityValue, entityInfo) {
228 + // Update entity value
229 + $('SomeSPace.SomeClass_0_entity_suggest').value = entityInfo;
230 + var serviceURL = new XWiki.Document('SomePageone', 'SomeSpace').getURL('view');
231 + var ajx = new Ajax.Request(serviceURL, {
232 + method: 'get',
233 + parameters: 'xpage=plain&outputSyntax=plain&entity=' + encodeURIComponent(entityValue),
234 +
235 +{{/code}}
236 +
208 208  = Javascript parameters for the ##XWiki.widgets.Suggest## constructor =
209 209  
210 210  |=Parameter|=Details|=Default value

Get Connected