Ја сам радио много од КССЛТ и јКуери и помислио бих поделим неколико исечака које други могу бити од користи у будућности.
Пример 1: Емит једноставан ЈаваСцрипт / јКуери у КССЛТ:
<клс:template match="something" КСМЛ:space="preserve">
<!– Празнина се упита пријатељски филтери скривено поље –>
<script type="text/javascript">
$(документ).спреман(функција(){
$("#QueryFriendlyFilters").val("empty");
});
</скрипта></клс:шаблон>
That bit emits some JavaScript that waits for the page to finish loading (because of the $(документ).спреман(...)) and then sets the value of a hidden field named QueryFriendlyFilters to the literal value “empty”.
Пример 2: Коришћење <клс:ако> to check “greater than”, “less than”, итд.
<клс:template match="something" КСМЛ:space="preserve">
<div id="fdcAllFilters">
<клс:if test="@Count>0">
<span class="fdcFilterLabel">Current filters:</распон>
</клс:ако><!– more stuff happens here. –>
</клс:шаблон>
The above snippet checks to see if an attribute named “Count” of the “something” element is greater than zero. The XML behind this would be something like:"
<something Count=”5” />
Пример 3: Iterate through all elements, interspersing jQuery calls.
<!– Iterate through all the filters and display the correct линкови. –>
<клс:for-each select="UserFilter"><a class="FilterHref" href="javascript:mySubmitPage(‘RemoveUserFilter’,'{@ ИД}’)">[X]</a>
<span class="fdcFilterLabel"><клс:value-of select="@FilterValue"/></распон>
<script type="text/javascript">$(документ).спреман(функција(){
<клс:текст><![ЦДАТА[$("#QueryFriendlyFilters").val( ($("#QueryFriendlyFilters").val() + " ]]></клс:текст>\"<клс:value-of select="@FilterValue"/>\"<клс:текст><![ЦДАТА["));]]></клс:текст>
});</скрипта>
</клс:-за сваки>
The above snippet is the most complex and there may be easier ways to do it.
The XML behind this looks roughly like this:
<UserFilter ID=”123” FilterValue=”xyzzy” />
This snippet is iterating through <UserFilter> nodes.
It first emits an anchor tag that when clicked invokes a JavaScript function that is already on the page, “mySubmitPage” and passes the value of an attribute on the <UserFilter> node named “ID”.
It then emits some jQuery that waits for the page to load. That jQuery updates a hidden field named “QueryFriendlyFilters” by adding the value of the FilterValue attribute. Note all the crazy <клс:текст> и <![ЦДАТА[ ... ]]> stuff.
That’s it, Надам се да помаже!
</крај>
Следите ме на Туиттер на http://www.twitter.com/pagalvin
Can I use this approach to filter multiple list webparts in SharePoint via a XSLT?
Ћао, Жао ми никада није одговорио на ово. It’s ancient at this point and so I won’t try. I hope you figured out what you were trying to do :).