pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)
Res facta quae tamen fingi potuit ([personal profile] pauamma) wrote in [site community profile] dw_dev_training2010-09-01 09:39 pm
Entry tags:

jQuery, need_res, and set_active_resource_group

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)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[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.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[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)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[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.