Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to start using jQuery in a Zend Framework 1.9 application?

Tags:

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?

like image 436
Andrew Avatar asked Oct 24 '09 03:10

Andrew


People also ask

What is the basic need to start with jQuery?

Before you start studying jQuery, you should have a basic knowledge of: HTML. CSS. JavaScript.

Is jQuery used in 2022?

It's good to know jQuery and there are still use cases for it. However, you should not spend a lot of time learning it. jQuery should not be your focus this year. The biggest advantage of jQuery now is that you can manipulate the DOM with less code.

Which jQuery method is used to set one or more style properties to the selected element?

jQuery css() Method The css() method sets or returns one or more style properties for the selected elements.

Should I use jQuery or JavaScript?

Though JavaScript is the basic language from which jQuery has evolved, jQuery makes event handling, DOM manipulation, Ajax calls much easier than JavaScript. jQuery also allows us to add animated effects on our web page which takes a lot of pain and lines of code with JavaScript.


1 Answers

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:

protected function _initViewHelpers() {     $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");     $view->jQuery()->addStylesheet('/js/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css')         ->setLocalPath('/js/jquery/js/jquery-1.3.2.min.js')         ->setUiLocalPath('/js/jquery/js/jquery-ui-1.7.2.custom.min.js'); } 

Step 5: Now add the jQuery view helper to your layout file:

<head>     <?php echo $this->jQuery(); ?> </head> 

Step 6: To test that you have everything working, add this line to one of your view scripts:

Pick your Date: <?php echo $this->datePicker("dp1", '', array('defaultDate' => date('Y/m/d', time()))); ?> 

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.

like image 69
Andrew Avatar answered Sep 28 '22 01:09

Andrew