Forum Discussion
Will definitely leverage this. Thanks!
These endpoints and macros are areas I've never worked with before. To everyone that has replied, thanks for the help!
Doug
It took a bit of tweaking, but I did get it working. Again, thanks so much for your help!
Inside the custom component I added an onclick element to the Language links of:
<a href="#" onclick="changelanguage('en');">English</a> <a href="#" onclick="changelanguage('es');">Spanish</a>
and at the bottom of the custom component added the tweaked script you provided
<script type="text/javascript"> function changelanguage(new_lang_code){ LITHIUM.jQuery.ajax({ type: "GET", url: "url_to_endpoint/endpoint_name?lang=" + new_lang_code, dataType: "json", success: function (data) { if(data.response == "success"){ window.location.reload(); }else{ return false; } } }); } </script>
Works great!
Will be live in our community soon.
Doug
- HaidongG11 years agoLithium Alumni (Retired)
Hi Doug,
I am glad to hear that my code helps you.
btw: I have just tried to solve the issue with a different approach with Page initialization, you can find more code sample on this link http://lithosphere.lithium.com/t5/developers-discussion/Change-users-language-preference-with-REST-API/m-p/129671#M4970
Related Content
- 10 days ago
- 11 months ago
- 9 months ago
- 2 years ago