1

Currently working with ZF and ZendX_JQuery.

As I understand, script links to Google's CDN JQuery are only included in the <head> section of a view if ZF JQuery is referenced in some way in the MVC.

However, I'm working with 'Cloud Zoom', a JQuery library for image zooming.

The view I wish to include Cloud Zoom in has no reference to JQuery, and therefore the script links are not included in the head. How can I make ZF include the script links in the head section of the page without explicitly including any ZF JQuery references in the MVC?

3
  • 1
    Not sure this is what you want, but you can manipulate head section using HeadScript view helper from your views. Commented Mar 23, 2011 at 12:25
  • That doesn't really make sense, you are working in the MVC (as i take it) and you want to use jQuery, but you don't want to reference it within the MVC? You can enable and disable zendx jquery with the view helper. That way you can have the code in your layout but only reference it on the few occasional views that require it. Commented Mar 23, 2011 at 12:45
  • Hi all, Thanks for the replies. I have zendx jquery enabled with the view helper. However, the links to the jQuery script file (hosted on Google's CDN) are only placed in the view output when a zendx jquery element is referred to in the view (e.g. through ZendX_JQuery_Form_Element_DatePicker). I'd like to know if there's a way to insert the jQuery script links without need to reference a zendx jquery element. I suppose the last resort would be to manually insert the script links using Marcin's headscript view helper suggestion? Commented Mar 23, 2011 at 13:09

1 Answer 1

1

from http://framework.zend.com/manual/en/zendx.jquery.view.html

To access the javascript we have to utilize the jQuery() functionality. Both helpers already activated their dependencies that is they have called jQuery()->enable() and jQuery()->uiEnable()

i have this code in my layout

if ($this->jQuery()->isEnabled()) {
    $this->headScript()->appendFile('/scripts/jquery.ui.datepicker-it.js');//localizazione di DatePicker
    echo $this->jQuery()->setRenderMode(ZendX_JQuery::RENDER_JAVASCRIPT | ZendX_JQuery::RENDER_JQUERY_ON_LOAD);
}

so i guess you have to do something like $this->jQuery()->enable()->enableui()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.