-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds noResults option #215
base: master
Are you sure you want to change the base?
Conversation
Hello! Sorry to barge in but I am rather keen to incorporate this feature into my own site and wanted to lend a hand in testing. I appreciate I am not the developer of EAC itself but hope this is of use. When I have used this version of EAC I receive the error: Something that would be helpful is to provide some indication of how to call the "noResults" option (where it sits in the options block, for example). Any questions let me know. Thanks, |
Hi Elliot, Did you get it to work? from the look of it and the changes it looks like all you need to do is to just add noResult: true and if the no result, yu will get no result in the drop down, right? Cheers, |
I did not, I am afraid. After tooling around and posting the above note I shrugged and moved back to the main branch of EAC as testing was taking up a lot of time and I did not hear back. |
Hello Elliot, I did a bit of digging into the code and I came up with the below: in jquery.easy-autocomplete.min.js Replace: if (0!==l.length) { " + c[i].header + " ");for (var m = 0, n = l.length; n > m && h < c[i].maxListSize; m += 1) e = $(" var a = m, b = h, f = c[i].getValue(l[a]); e.find(" > div").on("click", function() { t.val(f).trigger("change"), w = b, j(b), o.get("list").onClickEvent(), o.get("list").onChooseEvent() }).mouseover(function() { w = b, j(b), o.get("list").onMouseOverEvent() }).mouseout(function() { o.get("list").onMouseOutEvent() }).html(q.build(g(f, d), l[a])) }(), f.append(e), v.push(l[m]), h += 1 } with: if (l !== undefined) { " + c[i].header + " ");for (var m = 0, n = l.length; n > m && h < c[i].maxListSize; m += 1) e = $(" var a = m, b = h, f = c[i].getValue(l[a]); e.find(" > div").on("click", function() { t.val(f).trigger("change"), w = b, j(b), o.get("list").onClickEvent(), o.get("list").onChooseEvent() }).mouseover(function() { w = b, j(b), o.get("list").onMouseOverEvent() }).mouseout(function() { o.get("list").onMouseOutEvent() }).html(q.build(g(f, d), l[a])) }(), f.append(e), v.push(l[m]), h += 1 } else { f.append(" noResults } This would achieve 2 things:
number 1 above is achieved but number 2 is not so may be if you can help by defining what can we put in the else clause to have #2 achieved it would be great. Will keep digging. I highlighted the changed I have made above in bold text Will send it by email as it looks like the above is not rendered correctly. Cheers, |
Hi Elliot, Here is what I have done: replaced the below block: if (0!==l.length) {
} with the below block: if (l !== undefined) {
} else {
} I highlighted the changes I have made in red. The if (l !== undefined) works and the javascript doesn't crash. The problem is the below block is where you can define what would be in the drop down list but for some reasons it doesn't work. else {
} Will keep digging. If you can find anything to help in the second block, please let me know. Cheers, From: Elliot Page [email protected] I did not, I am afraid. After tooling around and posting the above note I shrugged and moved back to the main branch of EAC as testing was taking up a lot of time and I did not hear back. You are receiving this because you commented. |
I was able to get this working using @dmitov code. There is an error in the PR though. In his PR file: src/core.js Line 311 should be |
Hi Elliot, I had a crack at this and I made it. I'm using custom templates to read from RESTful APIs and display the results in a drop down list. What I have done is that I have changed the RESTful API to have the return results as per the below in case no record is found. { In the EA JavaScript code:
The above gave me the below results [cid:6ec7e826-0e5c-46a5-a2c2-60f64ad91dfd] If you have any questions, please let me know. Cheers, From: Elliot Page [email protected] I did not, I am afraid. After tooling around and posting the above note I shrugged and moved back to the main branch of EAC as testing was taking up a lot of time and I did not hear back. You are receiving this because you commented. |
Hi All, In case anyone else sees this , I've created a PR with the fix suggested by @kevinLay7 above. If you're using NPM I've also created a release on my fork with this functionality. See my PR for the release info. |
@@ -307,6 +307,10 @@ var EasyAutocomplete = (function(scope) { | |||
} | |||
} | |||
|
|||
if (config.get("noResults") && counter == 0) { | |||
$listContainer.append("<li><div class='eac-item'>" + config.get("noResults + </div></li>")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an error here, you put brackets in wrong place, can you fix it?
Adds
noResults
option.False by default.