I want to get started working with jQuery in my Zend Framework application but not sure which is the best way to get started. I know I could include the jQuery library just like any other javascript library, but what are the advantages of using ZendX_JQuery, and what are the steps necessary to start using it in my Zend Framework 1.9 application?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
The Solution is - >
I just shifted my Code from _initViewHelpers to _initView
and it works for me.
Just wanted to add that you have to (or at least I had to) enable the jquery and jquery components in the _initViewHelpers function:
One little gotcha:
You have to add the ZendX folder to your library directory - the one which also has your Zend directory.
If you miss adding ZendX to your library directory, you get lots of errors messages like this:
Another little gotcha:
In the code presented by Andrew above, note the important words highlighted:
While
$this->jQuery()
must go in the layout file so that all pages get jquery functionality, the actual jQuery code must go to the view file itself -application/views/scripts/yourcontroller/youraction.pthml
- it does not work in the layout with just this simple code.As user117640 sad,
I had to enable the jQuery and UI, it can be done in:
bootstrap :
controller::someAction :
view someAction.phtml:
include this to ur bootstrap file
Add this to ur layout
and use jQuery UI functions in ur view file: Pick your Date:
I was able to get jQuery working in my 1.9.4 project by following these steps:
Step 1: Copy the ZendX directory to your library directory. ZendX can be found in the extras/library directory of your Zend Framework download.
Step 2: Download jQuery and the jQuery UI library from jqueryui.com. I chose the UI Lightness theme.
Step 3: Extract the download and rename jquery-ui-1.7.2 to jquery and move to your public/js directory.
Step 4: Add these lines to your bootstrap file:
Step 5: Now add the jQuery view helper to your layout file:
Step 6: To test that you have everything working, add this line to one of your view scripts:
Now, if you open this page in your browser, there should be a text field. You should be able to click on the text field, which automatically pops up a calendar that has been styled to the UI Lightness theme.