[ckan-dev] {% scripts %} tag

Thodoris Papadopoulos thodoris at thodoris.net
Tue Mar 26 13:53:03 UTC 2013


We need to run a javascript only after jquery has been loaded AND only in
homepage.
The script is like this
<script>
$(function() {
 $('#homepage-promo-container').DoSomething();
});

Resources are not a solution becaouse the script will be loaded in all
pages.
if we place the script inside home/index.html it is loaded before query.
We tried to move the  {% block scripts %} somewhere in the header but it
didn't worked.

Any idea how we can achive both requirments ?

Thanks
Thodoris



On Tue, Mar 26, 2013 at 12:07 PM, Toby Dacre <toby.okfn at gmail.com> wrote:

> On 25 March 2013 21:14, Matt Moyles <matt.moyles at matricresearch.com>
> wrote:
> > I'm having a problem getting my script to be added to the bottom of the
> list. I need to load my script after jquery.
> >
> > Currently, I'm trying this:
> >
> > {% block scripts %}
> > {{ super() }}
> > <script src="/ckanext-news/js/homepage.js"></script>
> > {% endblock %}
> >
> > but in the output I am getting:
> >
> > <script src="/ckanext-news/js/homepage.js"></script>
> > <script>document.getElementsByTagName('html')[0].className += '
> js';</script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/jquery.js"></script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/bootstrap/js/bootstrap-transition.js"></script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/bootstrap/js/bootstrap-collapse.js"></script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/bootstrap/js/bootstrap-modal.js"></script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/bootstrap/js/bootstrap-alert.js"></script>
> > <script type="text/javascript"
> src="/fanstatic/vendor/:version:2013-03-12T20:56:49.75/bootstrap/js/bootstrap-tab.js"></script>
> >
> > I've been hunting through the layout_base.html and layout.html templates
> but have been unable to figure this out. Do I need cache the script with
> fanstatic? If so, is there a guide on how to use fanstatic?
>
> Matt,
>
> have a look here
> http://docs.ckan.org/en/latest/resources.html
>
>
> >
> > Matt
> >
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > http://lists.okfn.org/mailman/listinfo/ckan-dev
> > Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: http://lists.okfn.org/mailman/options/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20130326/00bebbd0/attachment-0001.html>


More information about the ckan-dev mailing list