0

jQuery is not loading in new window in Joomla

I have a page default.php in component module. default.php contains

defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
JHtml::_('jquery.framework');

And in default.php jQuery is successfully loaded and in console shows

jQuery().jquery;
"1.12.4"

In my default.php file I have a link, when I click that link it open a new window.

window.open("?view=report&format=raw&uid=" + ibonum, 'myWin', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=yes, width=960, height=741');

In that page I use the code to load jquery:

defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
JHtml::_('jquery.framework');

But here (new window) jQuery is not loaded. Console shows:

jQuery().jquery;
 Uncaught ReferenceError: jQuery is not defined
    at <anonymous>:1:1

And also here $document->addScript is also not working.

so my question is: How I load jQuery in new window i Joomla?

My joomla version is 3.9.2

2
  • Could you please also copy your jQuery script in your question, the script you want to run in the new window. Do you run that script in the original window, or that script should be running in the new window only?
    – Zollie
    Commented Jan 28, 2019 at 6:06
  • In orginal window jquery is working, but in new window jquery not working. Since there is no scope for jquery in new window I can't write any jquery code in new window. Commented Jan 28, 2019 at 6:12

1 Answer 1

1

This is expected. As indicated by format=raw parameter in the URL, the page you are trying to open is a raw document and not a HTML document. Raw document only renders what's outputted by the component's view.

4
  • can I change to format=html , but gives 500 - Layout default not found. Commented Jan 28, 2019 at 7:31
  • It means there's no default.php layout file for report view.
    – Sharky
    Commented Jan 28, 2019 at 7:36
  • How can I make it working? any suggestions?? Commented Jan 28, 2019 at 9:53
  • Sharky got the point since his answer is giving the light on the question. @DeepuSasidharan - You should just create default.php file in the report folder (and view) of whatever your component is and a layout of the page should be built up in that file. Please study Joomla and the documentation of Joomla at least a bit before you try to work with Joomla at all...
    – Zollie
    Commented Jan 28, 2019 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.