Yaron Koren has submitted this change and it was merged.

Change subject: Fixed problem with remote autocompletion in tokens and combobox 
for private wikis
......................................................................


Fixed problem with remote autocompletion in tokens and combobox for private 
wikis

Change-Id: Ifcee0c0e71e2ce844514388b74607ae4cfa23895
---
M libs/ext.sf.select2.combobox.js
M libs/ext.sf.select2.tokens.js
2 files changed, 20 insertions(+), 12 deletions(-)

Approvals:
  Yaron Koren: Verified; Looks good to me, approved



diff --git a/libs/ext.sf.select2.combobox.js b/libs/ext.sf.select2.combobox.js
index ca6e6ae..cccfab9 100644
--- a/libs/ext.sf.select2.combobox.js
+++ b/libs/ext.sf.select2.combobox.js
@@ -193,7 +193,7 @@
 
                var ajaxOpts = {
                        url: my_server,
-                       dataType: 'jsonp',
+                       dataType: 'json',
                        data: function (term) {
                                return {
                                        substr: term, // search term
@@ -201,11 +201,15 @@
                        },
                        results: function (data, page, query) { // parse the 
results into the format expected by Select2.
                                var id = 0;
-                               data.sfautocomplete.forEach( function(item) {
-                                       item.id = id++;
-                                       item.text = item.title;
-                               });
-                               return {results: data.sfautocomplete};
+                               if (data.sfautocomplete !== undefined) {
+                                       data.sfautocomplete.forEach( 
function(item) {
+                                               item.id = id++;
+                                               item.text = item.title;
+                                       });
+                                       return {results: data.sfautocomplete};
+                               } else {
+                                       return {results: []};
+                               }
                        }
                };
 
diff --git a/libs/ext.sf.select2.tokens.js b/libs/ext.sf.select2.tokens.js
index df1d474..3be0223 100644
--- a/libs/ext.sf.select2.tokens.js
+++ b/libs/ext.sf.select2.tokens.js
@@ -237,7 +237,7 @@
 
                var ajaxOpts = {
                        url: my_server,
-                       dataType: 'jsonp',
+                       dataType: 'json',
                        data: function (term) {
                                return {
                                        substr: term, // search term
@@ -245,11 +245,15 @@
                        },
                        results: function (data, page, query) { // parse the 
results into the format expected by Select2.
                                var id = 0;
-                               data.sfautocomplete.forEach( function(item) {
-                                       item.id = id++;
-                                       item.text = item.title;
-                               });
-                               return {results: data.sfautocomplete};
+                               if (data.sfautocomplete !== undefined) {
+                                       data.sfautocomplete.forEach( 
function(item) {
+                                               item.id = id++;
+                                               item.text = item.title;
+                                       });
+                                       return {results: data.sfautocomplete};
+                               } else {
+                                       return {results: []};
+                               }
                        }
                };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/155899
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcee0c0e71e2ce844514388b74607ae4cfa23895
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Jatin <mehtajati...@gmail.com>
Gerrit-Reviewer: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to