[ckan-dev] {% scripts %} tag

Toby Dacre toby.okfn at gmail.com
Tue Mar 26 14:05:45 UTC 2013


On 26 March 2013 13:53, Thodoris Papadopoulos <thodoris at thodoris.net> wrote:
> 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.

Resources are the ONLY solution.  You need to use them to add
javascript to pages.
you need to create the script as a resource and the include it on the
page you wish using the {% resource %} tag


> 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
>
>
>
> _______________________________________________
> 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
>




More information about the ckan-dev mailing list