We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Scripts added from init.php non triggering on mobile layout | Forum

Andrea De Santis
Andrea De Santis Nov 17 '15

Hi!


I am building a very simple plugin that needs to attach (or render) a javascript into the page.


The plugin is complete and it's working fine on the desktop version, anyway I am facing a very odd issue with the mobile layout. The script is rendered correctly but is not executed at all!


I am using the default theme with no modifications.


Basically I am adding a script form the init.php, 

just to simplifly the debug  I used a naive alert box:


OW::getDocument()->addOnloadScript(" window.onload = function() { alert('ok'); }",1);


which renders 


(function(_scope) { window.onload = function() { alert('ok'); }})({});


I can see the "ok" alert box on desktop devices but looks like the

code is not executed on the mobile version (of course I checked, the code is into the html page).


also tried


-  static external script using OW::getDocument()->addScript

-  appendBody with direct <script></script> injection


...same outcome, code is correctly rendered into the page but not running.


Am I missing something?! Maybe I should to use "OW.bind(...) " or something similar?


Thanks in advance,

Andrea

Andrea De Santis
Andrea De Santis Nov 17 '15
Fixed :)


My fault, I was completely unaware that I had to create a specific version

and place it into the /mobile subfolder... anyway not documented anywhere (or at least I haven't found it).