pauamma: Cartooney crab holding drink ("Cartooney crab holding drink")pauamma ([personal profile] pauamma) wrote in [site community profile] dw_dev_training,
@ 2010-09-01 09:39 pm UTC
Entry tags:jquery, template toolkit
Is there a Wiki page (or something) on using jQuery on DW? I'm confused on what the group option to need_res is for vs. set_active_resource_group. And I need that info so I can update the TTization page (http://wiki.dwscoalition.org/notes/Routing_and_Template_Toolkit)


(5 comments) - (Post a new comment)
(Flat) (Top-level comments only)

afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2010-09-02 01:55 am UTC (link)
Hm, I don't recall if there is.

The group option allows you to set the group for a particular set of files.
set_active_resource_group sets which of the groups should be active on the current page.

The distinction is useful in site schemes, for example, so that they can include the proper file depending on whether the page wants jquery or not.

(Reply to this)  (Thread


pauamma: Cartooney crab holding drink ("Cartooney crab holding drink")


[personal profile] pauamma
2010-09-02 03:20 pm UTC (link)
So in the TT template for a page that uses jQuery and page-specific JS some of which doesn't rely on jQuery, I might need to do something like:
[% dw.need_res( 'css/ponies.css' ); %]
[% dw.need_res( 'js/ponies.js' ); %]
[% dw.need_res( ( group => 'jquery' ), 'js/sparkle.js' ); %]
[% dw.set_active_resource_group( 'jquery' ); %]
Is that correct?

(Reply to this)  (Thread from start)  (Parent)  (Thread


afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2010-09-02 05:03 pm UTC (link)
Yes! You can combine multiple files into one need_res, too, so, something like:

[%- CALL dw.active_resource_group( "jquery" ) -%]
[% dw.need_res( { group => 'jquery', optimize => 1 },
"js/jquery/jquery.ui.core.js",
"js/jquery/jquery.ui.widget.js",
"js/jquery/jquery.ui.mouse.js",
"js/jquery/jquery.ui.position.js",
"js/jquery/jquery.ui.draggable.js",
"js/jquery/jquery.ui.droppable.js",
"js/jquery/jquery.ui.selectable.js",
"js/jquery/jquery.ui.sortable.js",
"js/jquery/jquery.ui.datepicker.js",
"js/jquery/jquery.ui.dialog.js",
"js/jquery/jquery.ui.autocomplete.js" ) %]

[% dw.need_res(
"stc/jquery/jquery.ui.base.css",
"stc/jquery/jquery.ui.core.css",
"stc/jquery/jquery.ui.autocomplete.css",
"stc/jquery/jquery.ui.datepicker.css",
"stc/jquery/jquery.ui.dialog.css",
"stc/jquery/jquery.ui.selectable.css"
) %]


(which is from my tt-ization of the posts page)

(Reply to this)  (Thread from start)  (Parent


afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2010-09-02 05:04 pm UTC (link)
Oh, the CALL is important because for some reason, active_resource_group returns the value? And it gets printed out.

(Reply to this)  (Thread from start)  (Parent)  (Thread


pauamma: Cartooney crab holding drink ("Cartooney crab holding drink")


[personal profile] pauamma
2010-09-02 07:26 pm UTC (link)
Yeah, I had the same problem with the set ML scope thing. Thanks.

(Reply to this)  (Thread from start)  (Parent



(5 comments) - (Post a new comment)
(Flat) (Top-level comments only)