Forums / Discussions / Tip: Javascript and eZ publish communication using user preferences
Thursday 18 August 2011 3:33:29 pm - 2 replies
In this post I will show an easy way to make eZ publish communicate with javascript.
» Read full blog post
Damien Pobel
Saturday 20 August 2011 1:59:43 pm
Hi Tiago,
I've just opened a pull request that adds a built in function to do that, if it's accepted, you're code could be transformed in :
<input type="checkbox" id="var_test" name="var_test"{if eq( ezpreference('var_test'), 'true' )} checked="checked"{/if}> Test <script type="text/javascript"> {literal} $("#var_test").change(function() { $.ez.setPreference('var_test', $("#var_test").is(":checked")); }); {/literal} </script>
PS: setting cache_ttl to 0 should not be necessary, if you have cache issues regarding preferences, you should look at the CachedViewPreferences settings.
Cheers
Damien Planet eZ Publish.fr : http://www.planet-ezpublish.fr Certification : http://auth.ez.no/certification/verify/372448 Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish
Thiago Campos Viana
Sunday 21 August 2011 5:25:27 pm
wow! Nice, thank you!
eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924 Twitter: http://twitter.com/tcv_br
You must be logged in to post messages in this topic!