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

How to extend Suit Bootstrap? (include js after bootstrap.min.js) #149

Closed
macedd opened this issue Sep 13, 2013 · 4 comments
Closed

How to extend Suit Bootstrap? (include js after bootstrap.min.js) #149

macedd opened this issue Sep 13, 2013 · 4 comments

Comments

@macedd
Copy link

macedd commented Sep 13, 2013

In suit, bootstrap.min.js is included within the template after the page content.

Bootstrap plugins needs to be included after the bootstrap.min.js inclusion. I'm willing to use the Media class to include this files, as needed.

The problem is that Media files are included in the head, so they cant extend bootstrap, which is instantiated later.

Any tips on the best way to overpass this issue?

@darklow
Copy link
Owner

darklow commented Sep 13, 2013

The fastest solution, but not the cleanest, i could think of is adding bootstrap.min.js to extrahead before {{ block.super }} where the {{ media.js }} is included later.

You can do this in base_site.html template file.
Unfortunately it means boostrap.min.js will be included twice, but it should work until i find and implement some proper fix.

{% block extrahead %}
  <script src="{% static 'suit/bootstrap/js/bootstrap.min.js' %}"></script>
  {{ block.super }}
{% endblock %}

@macedd
Copy link
Author

macedd commented Sep 17, 2013

I had to move the declarations from footer to head, as you mentioned, but cleaning also suit/templates/admin/base.html suit and bootstrap declarations.
On the redeclaration (footer bootstrap.min.js) the extends gone with the wind.

Is this a viable fix? (to move js to head)

django-sekizai seems to be putting the JSs in the footer. Maybe we can look at their code

@darklow
Copy link
Owner

darklow commented Sep 17, 2013

The fix is easy one, but the decision either to move bootstrap.min.js to head or move {{ media.js }} to footer near other scripts is the hard one, still thinking of pros/cons for each.

@darklow
Copy link
Owner

darklow commented Sep 17, 2013

I moved bootstrap.min.js to <head> before {{ media.js }}.
Please test if it works correctly using latest development version:

pip uninstall django-suit
pip install https://github.com/darklow/django-suit/tarball/develop

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

No branches or pull requests

2 participants