Comments (13)
This seems reasonable to me. Currently I'm hiding the menu when there is nothing found in the collection. Will this conflict with your goal?
https://github.com/zurb/tribute/blob/master/js/tribute.js#L197
from tribute.
Good question, it would be nice to be able to keep the menu available even when there is no result to give the event enough time to load another collection. Perhaps a loading state is in order?
from tribute.
To expand on that last thought: my project has a custom loading .gif
and it would be great to display that in the menu as a dummy list item while the other collection loads. You could possibly also have a config option to keep the list hidden for those who don't care about a loading state like me :)
from tribute.
This makes sense, so maybe if you define an noMatchTemplate
function we then load that instead of hiding the list?
from tribute.
That would be great!
from tribute.
Please test this pull request: #17
from tribute.
Looking good so far, just a couple things I've noticed based on how I think it should work:
- After the collection is updated inside the
tribute-no-match
event, the list continues to render thenoMatchTemplate
instead of updating to show new results. - When you backspace to start filtering again (because the list doesn't update on its own), two lists begin to render, one behind the other.
- The enter key no longer inserts the mention, instead a mouse click is required.
- It seems the event fires at least twice when there is no match, but that could be a symptom of my code. In my experience it fires even when the list has been updated and there is in-fact a match. Below is some pseudo code that mimics what I'm doing.
var t = new Tribute({
values: window.mentions,
menuItemTemplate: function (item) {
return '<li>' + item + '</li>';
},
noMatchTemplate: function (tribute) {
return '<li>Finding more...</li>';
},
selectClass: 'selected',
});
// bind to element
t.attach(element);
// if no match is found, request another page and update list
element.addEventListener('tribute-no-match', function(e) {
var xhr = new XMLHttpRequest();
// abort multiple requests
try {
xhr.abort();
}
catch(e) {}
xhr.open('GET', '/following?action=get_following_for_mentions&get_remainder=true');
xhr.send();
xhr.addEventListener('load', function() {
if (xhr.status === 200) {
var response = JSON.parse(xhr.response);
t.collection[0].values.push(response);
}
});
});
from tribute.
@mattschwarz Thank you for testing it out! I'll take a look at this today.
from tribute.
@mattschwarz I have pushed up a bunch of fixes to that pull request. Along with the fixes in #18, there may be enough here for a major release. As far as the multiple calls to no-match
, this happens because a lookup is fired on each keyup event. If collection values are being manipulated, you will have to be sure that duplicates are not inserted.
I have added the appendCurrent(values)
and append(index, values)
helper methods to make updating the current and arbitrary collections much easier.
from tribute.
I've merged into master, seems to be working pretty well.
from tribute.
Great, will test!
from tribute.
Hi, is there any way to add the no match text in current collection or select it
I mean suppose I write #thisIsHash and that is not in the value list , still want to have possibility to select this
from tribute.
How can we add click event on image in noMatchTemplate function template in angular?
noMatchTemplate: function(item) { return '
from tribute.
Related Issues (20)
- Wrong mention menu position on meta (shift, cmd, ctrl, alt) keyups HOT 2
- MLK Jr. Tribute page
- tributejs npm package version 5.1.3 is lastest, but not have loadingItemTemplate in options HOT 1
- Hi, why I can't use arrow key on my mention tooltip HOT 1
- Menu is offset incorrectly
- Cannot set cursor in front of the mention tag
- DOM-based XSS due to un-escaped special characters HOT 1
- Is it possible to add dropdown with heading?
- Removing items with backspace is not working when added by showMenuForCollection menu HOT 3
- Removing characters one by one with backspace then auto suggesting is not working HOT 1
- Instead of characters matches, is there words can match
- latest Typescript complile error
- Option to use DOM elements instead of HTML strings as templates
- Typescript 4.8.2 (Required by Angular 15) TributeOptions Type issue
- Update to stimulus-use debounce broke remote data load
- Error while clicking on scroll bar - chrome on mac
- Replacing words that contains space
- Performance issue and freezes
- When we can have a new version with the latest changes from master? HOT 2
- Tribute doesnot seem to work inside bootstrap modal.
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 tribute.