Nimekuwa kufanya mengi ya ya XSLT na jQuery na mawazo ningependa kushiriki snippets wachache wengine wanaweza kupata manufaa katika siku zijazo.
Mfano 1: Emit JavaScript rahisi / jQuery katika XSLT:
<xsl:template match="something" xml:space="preserve">
<!– Tupu nje ya swala filters kirafiki siri shamba –>
<script type="text/javascript">
$(hati).tayari(kazi(){
$("#QueryFriendlyFilters").val("empty");
});
</script></xsl:template>
Kwamba kidogo hutoa baadhi JavaScript kwamba tusubiri kwa ukurasa kumaliza upakiaji (kwa sababu ya $(hati).tayari(...)) na kisha unaweka thamani ya shamba siri aitwaye QueryFriendlyFilters kwa thamani halisi "tupu".
Mfano 2: Kutumia <xsl:kama> kuangalia "kubwa kuliko", "Chini ya", nk.
<xsl:template match="something" xml:space="preserve">
<div id="fdcAllFilters">
<xsl:if test="@Count>0">
<span class="fdcFilterLabel">Sasa filters:</span>
</xsl:kama><!– zaidi stuff kinachotokea hapa. –>
</xsl:template>
snippet juu ya hundi ya kuona kama sifa aitwaye "Count" ya kipengele "kitu" ni kubwa kuliko sufuri. XML nyuma ya hii itakuwa kitu kama:"
<kitu Count = "5" />
Mfano 3: Iterate kupitia mambo yote, interspersing wito jQuery.
<!– Iterate kupitia filters wote na kuonyesha sahihi viungo. –>
<xsl:for-each select="UserFilter"><a class="FilterHref" href="javascript:mySubmitPage(‘RemoveUserFilter’,'{@ ID}')">[X]</a>
<span class="fdcFilterLabel"><xsl:value-of select="@FilterValue"/></span>
<script type="text/javascript">$(hati).tayari(kazi(){
<xsl:Nakala><![CDATA[$("#QueryFriendlyFilters").val( ($("#QueryFriendlyFilters").val() + " ]]></xsl:Nakala>\"<xsl:value-of select="@FilterValue"/>\"<xsl:Nakala><![CDATA["));]]></xsl:Nakala>
});</script>
</xsl:kwa-kila>
snippet juu ni ngumu zaidi na kunaweza kuwa rahisi njia ya kufanya hivyo.
XML nyuma ya hii inaonekana takribani kama hii:
<UserFilter ID = "123" FilterValue = "xyzzy" />
Snippet hii ni iterating kupitia <Mtumiaji Filter> nodes.
Ni kwanza hutoa tag nanga kwamba wakati clicked waomba kazi JavaScript kwamba tayari ni juu ya ukurasa, "MySubmitPage" na hupita thamani ya sifa juu ya <Mtumiaji Filter> nodi aitwaye "ID".
Ni kisha hutoa baadhi jQuery kwamba tusubiri kwa ukurasa kupakia. Kwamba jQuery updates shamba siri aitwaye "QueryFriendlyFilters" kwa kuongeza thamani ya sifa FilterValue. Kumbuka mambo yote <xsl:Nakala> na <![CDATA[ ... ]]> mambo.
Hiyo ni, matumaini inasaidia!
</mwisho>
Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin
Can I use this approach to filter multiple list webparts in SharePoint via a XSLT?
Hi, sorry mimi kamwe waliitikia hili. It’s ancient at this point and so I won’t try. I hope you figured out what you were trying to do :).