Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

add_to_footer AFTER bootstrap

Asked Modified Viewed 1,876 times
R
Routh
R
Routh 10
Chris Routh
Founder of The Den of Amateur Writing

"Don't try to be a great man; just be a man and let history make its own judgments." - Riker, Star Trek The Next Generation
  • Member, joined since
  • Contributed 67 posts on the community forums.
  • Started 18 threads in the forums
  • Started this discussions
asked
Member

Hi,

I have a Bootstrap Javacript plugin I want to use, but it MUST be loaded after Bootstrap.min.js

Currently using the add_to_footer() function there is no way to do this, as it always adds it BEFORE Bootstrap.
0 replies

4 posts

J
jikaka
J
jikaka 10
www.rusfusion.ru - russian nss
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 82 threads in the forums
answered
Veteran Member

open file footer.php
and paste directly to </body>
0 replies
R
Routh
R
Routh 10
Chris Routh
Founder of The Den of Amateur Writing

"Don't try to be a great man; just be a man and let history make its own judgments." - Riker, Star Trek The Next Generation
  • Member, joined since
  • Contributed 67 posts on the community forums.
  • Started 18 threads in the forums
  • Started this discussions
answered
Member

In this case that doesn't work. I need to add this bootstrap plugin on demand from an infusion using the add_to_footer() function. Adding it to the theme would not be appropriate.

I managed to work around this by altering /themes/templates/layout.php and moving the bootstrap lines above the add_to_footer() output, but now I've changed a core PHPFusion file, which will be overwritten during an update. This is bad practice.

Optimally the add_to_footer() function should be adding extra JS scripts after bootstrap.min.js by default, or we should have an option to force it when necessary.

Most bootstrap javascript widgets and plugins require the core bootstrap.js to be loaded first anyway.
0 replies
K
KasteR
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums
answered
Senior Member

Haven't tested this at all, and I currently do not have R3 setup. If someone can test this and confirm that would be great. But here's an idea, maybe call your script via jQuery. JavaScript is client side, so this should be called after the rest has been parsed. Worth a shot.

Sorry I couldn't test before posting.

add_to_footer('<script>$.getScript( "script.js" </script>');
0 replies
R
Routh
R
Routh 10
Chris Routh
Founder of The Den of Amateur Writing

"Don't try to be a great man; just be a man and let history make its own judgments." - Riker, Star Trek The Next Generation
  • Member, joined since
  • Contributed 67 posts on the community forums.
  • Started 18 threads in the forums
  • Started this discussions
answered
Member

That might work, so long as the plugin isn't wrapped in something that would break the import. It's kind of an ugly solution but I'll try it. Not sure that this would help all scenarios.

In the end the best solution is for bootstrap to come out first in the javascript order.

I'll test this and report back though as it may help others in the meantim.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

R
R
Routh 10
Chris Routh
Founder of The Den of Amateur Writing

"Don't try to be a great man; just be a man and let history make its own judgments." - Riker, Star Trek The Next Generation
  • Member, joined since
  • Contributed 67 posts on the community forums.
  • Started 18 threads in the forums
  • Started this discussions
J
J
jikaka 10
www.rusfusion.ru - russian nss
  • Veteran Member, joined since
  • Contributed 946 posts on the community forums.
  • Started 82 threads in the forums
K
K
KasteR 10
  • Senior Member, joined since
  • Contributed 290 posts on the community forums.
  • Started 1 thread in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet