Comments (16)
No reason why we have a hard dependency on jQuery right now other than that's what we use. If we can verify typeahead.js works as expected with Zepto, I'd be ok with loosening up the hard dependency on jQuery to a dependency on jQuery or Zepto.
from typeahead.js.
Good to hear! 👍
I tried using typeahead.js + Zepto a few days ago to no avail unfortunately (obviously resolving the jQuery dependency manually for the time being). I started debugging the stack trace but didn't get far into looking into it.
If I have some free time over the next few weeks, I'll try to come up with a fix and submit a PR (if someone doesn't beat me to it first).
from typeahead.js.
FWIW, I tried to run the test suite using Zepto in place of jQuery, but the library we use for mocking out ajax requests, doesn't support Zepto. So if we were to support Zepto, we would first need to patch jasmine-ajax first. This isn't a big deal, just something to be aware of.
from typeahead.js.
Hmm, interesting... I haven't tried this out specifically yet. In looking through the commit logs, it looks like it was supported at one point? Now it says Supports both Prototype.js and jQuery
. 😦
What I don't know is if that means that it doesn't explicitly support Zepto, or if the two are incompatible altogether. I suppose I'll have to investigate further on that front.
from typeahead.js.
Seeing this closed, does this mean it was abandoned?
from typeahead.js.
It's something I have no interest in working on myself, but if someone submits a compelling pull request, I'd have no problem accepting it.
from typeahead.js.
Due to time constraints, we ended up not using typeahead.js for the project I was working on -- I'm also running low on extracurricular time to take on this task, so although I would love to see this happen, I more than likely won't be submitting a PR anytime soon.
from typeahead.js.
We analyzed this at my work to see how significant of an effort this would be to allow zepto to work instead of jquery, and it does seem rather significant. Many of the jquery dependencies exist in zepto however the substantial usage of deferred seems to be the most significant piece that does not exist in zepto. I can see why this was passed over.
from typeahead.js.
Yep, that's about the same conclusion that we arrived at. I would love to try to resolve the dependencies and make the library choice a non-issue, but as you mentioned, it's no trivial task (unfortunately).
from typeahead.js.
Hi,
@dotnetchris and @dsimmons have you seen this one: https://github.com/sudhirj/simply-deferred ?
I was trying to use typeahead with zepto, too. Would love to combine both.
Any chance you could post your work done so far?
from typeahead.js.
I didn't get very far before quickly realizing that it wouldn't be as easy as I thought it would, so I unfortunately discarded my work and moved on with a different approach. 😦 Sorry!
edit: @pheadeaux, I haven't checked that project out. Most of my non-jQuery deferred experience has been with q.
from typeahead.js.
I have started working on a project using the Zurb Foundation 4 framework and have managed to get typeahead.js working with Zepto (and jQuery) with remote and local data sources. Here is what I changed I haven't tried to pass all of the tests in typeahead.js yet but if this helps anyone with more free time I thought it would at least be worth sharing. First, Zepto.js by default doesn't have deferred support, so in addition to replacing jQuery with Zepto, I also included the excellent library simply-deferred. I also initialized it to make Zepto behave more closely to jQuery with this one line:
Deferred.installInto(Zepto);
Then I made the following changes to typeahead.js. At line 328 there is a block of code that is responsible for executing the $.ajax()
request (without this change any attempt to resolve the remote resource will only result in a request to the same page that the typeahead input is located (the effect being an ajax request with no URL)):
_sendRequest: function(url) {
var that = this, jqXhr = pendingRequests[url];
if (!jqXhr) {
incrementPendingRequests();
jqXhr = pendingRequests[url] = $.ajax(url, this.ajaxSettings).always(always);
}
This uses a jQuery shortcut of providing the URL as the first argument and the ajaxSettings object as the second argument. In Zepto $.ajax()
only takes one argument (a pattern that jQuery actually natively supports as well, the URL then object method is compensated for by type checking the first and second arguments), so I changed it to this block that work in both frameworks:
_sendRequest: function(url) {
var that = this, jqXhr = pendingRequests[url], ajaxOptions = {'url': url};
if (!jqXhr) {
incrementPendingRequests();
$.extend(ajaxOptions, this.ajaxSettings);
jqXhr = pendingRequests[url] = $.ajax(ajaxOptions).always(always);
}
Then at the end of typeahead.js there are two references to jQuery directly:
jQuery.fn.typeahead = function(method) {
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
} else {
return methods.initialize.apply(this, arguments);
}
};
})();
})(window.jQuery);
I changed that code to this:
$.extend($.fn, {
typeahead: function(method) {
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
} else {
return methods.initialize.apply(this, arguments);
}
}
});
})();
})(window.$);
And with that the code is now working (at least for my needs). I did have to add a bunch of CSS to compensate with the effects of the dynamically added HTML, but that is Foundation 4 Specific and I figured anyone who was working on just Zepto and typeahead would be interested in this.
from typeahead.js.
I've started working on a proper patch that adds in zepto.js support so far I have the changes I outlined in my previous comment and I've refactored the Jasmin tests so you can see that jQuery support is completely intact. the playground-zepto.html works but the automated tests are much more rigorous, because of the failed Jasmin tests with Zepto I don't think this is ready for a full on push, however if it helps anyone else here is my branch:
https://github.com/jasonsperske/typeahead.js/tree/zepto-support
from typeahead.js.
Once all of the relevant shims are in place, typeahead seems to work with zepto.js with the exception of this one selector..
.find(".tt-suggestions > .tt-suggestion");
As far as I can tell the immediate child selector isn't supported by zepto.
from typeahead.js.
Actually, now that you mention it, I think that might have been the realization that I'd had after shimming it myself locally before deciding to go ahead and switch gears because it was proving to be too much of a time sink.
from typeahead.js.
Tried my best to work with zepto. Finally ended up creating my own autocomplete/typeahead which works with zepto. zepto-autocomplete
, finally we have an autocomplete plugin native to zepto
.
https://github.com/yugal/zepto-autocomplete
Worked well for me in production :)
from typeahead.js.
Related Issues (20)
- Typeahead.bundle.js ERR_ABORTED 503 (Backend is unhealthy)
- Input value is lost on browser back button
- Can we show dropdown options on button click?
- System architecture documentation
- How do I change the source dynamically?
- This project is dead, please check https://github.com/corejavascript/typeahead.js HOT 6
- typeahead.js 0.11.1 doesn't render results when results are less than limit HOT 3
- Prevent http request base on custom characters or data types
- use as Edit in form
- dropdown-item href link HOT 1
- Documentation lacking key information HOT 1
- Suggestions not showing inside Table Row
- Unclear duplication (in the form of plain text) on input HOT 1
- How to restrict to enter free text in the TypeAHead component?
- Bloodhound matching not working with parenthesis and remote.
- A way to get the name of the data set while using multiple data sets
- 404 Search Issue (Heroku)
- New line isn't supported? || Line breaker
- Recharge after new registration HOT 1
- Mark as archived or deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeahead.js.