-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Fixed performance when there is a lot of item in the m2m relation and a visual glitch. #54
Conversation
visual glitch. Formerly the jQuery code was looping through all the potential <input> elements that could be added to the m2m relationship in order to find the parent <ul> elements. It is now done this other way around, we only loop through <ul> elements that have <input> child with the `sortedm2m` class. We are also hidding the <ul> until it gets fully prepared, to avoid to have a bad flicker when initially loading the page.
ping @gregmuellegger :-) |
<div class="sortedm2m-container"> | ||
|
||
<p class="selector-filter"> | ||
<img src="{% static "sortedm2m/selector-search.gif" %}" alt="" title="{% trans "Type into this box to filter down the list." %}" /> | ||
<input type="text" placeholder="{% trans "Filter" %}" /> | ||
</p> | ||
|
||
<ul> | ||
<ul class="hide"> |
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.
Could we make the hide
class be added by JS on load? The problem here I see is if you don't have JS enabled you will never see the checkboxes ... I'm not sure if I'm living in the 1990s in that regard, what do you think?
Hey, that's a super cool addition. Thanks for taking the time! I will merge it as soon as I know your opinion on the inline comment I made ;) |
I don't believe anybody will hit django's admin interface without js enabled nowadays but well, it's always better to be safe so I applied what you asked for ;-) |
ae86d6e
to
abda401
Compare
Awesome! Merged and released in 1.0.1 https://pypi.python.org/pypi/django-sortedm2m/1.0.1 |
Sweet! thanks for the release ;-) |
Formerly the jQuery code was looping through all the potential
<input>
elementsthat could be added to the m2m relationship in order to find the parent
<ul>
elements. It is now done this other way around, we only loopthrough
<ul>
elements that have<input>
child with thesortedm2m
class.
(With this change a page that would take 12sec to load before is now loading instantly.)
We are also hidding the
<ul>
until it gets fully prepared, to avoid to havea bad flicker when initially loading the page.