Store dynamic variables into the JavaScript language store#6006
Store dynamic variables into the JavaScript language store#6006gunjanpatel wants to merge 3 commits intojoomla:stagingfrom
Conversation
|
Why not using "normal" JS? $js = 'Joomla.MyNamespace.article = "' . $this->item->title . '";';
JFactory::getDocument()->addScriptDeclaration($js);alert(Joomla.MyNamespace.article);I'm not sure about abusing language function for "normal" variables. |
Reasons:
I didn't see any abuse of this function as it's using the same string store without disturbing |
|
works as advertised, but I'm not sure that the JText class should be misused in this way. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6006. |
|
Thanks for test @compojoom |
|
@text OK. Cool addition. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6006. |
|
Sorry, but I have to agree with @bembelimen here. This screams for misuse. |
|
Please keep the Joomla Code as clean as possible. Abusing a class is always bad practice and will cause misunderstandings and errors in the future. |
|
I have noticed a similar purpose in #3072 |
|
Thank you guys for review. It's better to close this PR then as per discussion it's going to abuse JText class. |
This patch will improve the functionality of
Joomla.JText._()javascript function by supporting dynamic variable declaration easily.For Example:
Let's try to get article title in javascript file.
components/com_content/views/article/tmpl/default.phpThis will print article title in browser console.
Backwards compatibility
Full b/c, no problems are expected
Testing instructions
Try to follow the given example.