Skip to content
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

Merged
merged 2 commits into from
Jun 18, 2015

Conversation

johnraz
Copy link
Contributor

@johnraz johnraz commented Jun 13, 2015

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.

(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 have
a bad flicker when initially loading the page.

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.
@johnraz
Copy link
Contributor Author

johnraz commented Jun 14, 2015

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">
Copy link
Collaborator

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?

@gregmuellegger
Copy link
Collaborator

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 ;)

@johnraz
Copy link
Contributor Author

johnraz commented Jun 18, 2015

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 ;-)

@gregmuellegger gregmuellegger merged commit abda401 into jazzband:master Jun 18, 2015
gregmuellegger added a commit that referenced this pull request Jun 18, 2015
@gregmuellegger
Copy link
Collaborator

Awesome! Merged and released in 1.0.1 https://pypi.python.org/pypi/django-sortedm2m/1.0.1

@johnraz
Copy link
Contributor Author

johnraz commented Jun 18, 2015

Sweet! thanks for the release ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants