adding jQuery js code to my view

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

adding jQuery js code to my view

backdoc-2
I'm trying to add jQuery to my view.  But, I'm missing something.  I can't seem to get the code loaded.

In my bootstrap.php, I have:
     set_include_path('../library:../application/models' . PATH_SEPARATOR . get_include_path());

In my "library path", I have two directories:  Zend and ZendX.

In my controller's init(), I have:
     $this->view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');

In my view (index.phtml), I have:
     <head> 
     <?php
             $this->jQuery()->enable();
             // enable and configure jQuery View Helper
             $this->jQuery()->setLocalPath("./js/jquery-1.2.6.min.js");
             //echo $this->jQuery(); 
     ?>
     .......... other stuff ..........
     </head>

I've tried echoing the jQuery() object, but I get an error.  I don't know if that's because I haven't done something else I should be doing, or if I'm not supposed to echo it.

My "./js/jquery-1.2.6.min.js" path works if I do:
     <script type="text/javascript" src="./js/jquery-1.2.6.min.js"></script>

I'm missing something conceptually.  Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: adding jQuery js code to my view

Benjamin Eberlei-2
Hello Darren,

first off, the jQuery helper is still in incubator status, so there might be
bugs.

The setup you described works for me perfectly though. Its probably important
what the exact error message is you are getting, but i have the feeling the
jQuery helper can not be found in your include path due too some
misconfiguration/spelling.

Echo'ing the jQuery helper is perfectly fine. it prints the currently known
jQuery configuration to that position in the view script.

btw, did you work with the docbook from svn oder did you check the demo pages?
if you haven't done the latter, www.beberlei.de/jquery/demo/ has some
use-cases and code.

Benny

On Sunday 28 September 2008 15:19:32 darren wrote:

> I'm trying to add jQuery to my view.  But, I'm missing something.  I can't
> seem to get the code loaded.
>
> In my bootstrap.php, I have:
>      set_include_path('../library:../application/models' . PATH_SEPARATOR .
> get_include_path());
>
> In my "library path", I have two directories:  Zend and ZendX.
>
> In my controller's init(), I have:
>      $this->view->addHelperPath('ZendX/JQuery/View/Helper/',
> 'ZendX_JQuery_View_Helper');
>
> In my view (index.phtml), I have:
>      <head>
>      <?php
>              $this->jQuery()->enable();
>              // enable and configure jQuery View Helper
>              $this->jQuery()->setLocalPath("./js/jquery-1.2.6.min.js");
>              //echo $this->jQuery();
>      ?>
>      .......... other stuff ..........
>      </head>
>
> I've tried echoing the jQuery() object, but I get an error.  I don't know
> if that's because I haven't done something else I should be doing, or if
> I'm not supposed to echo it.
>
> My "./js/jquery-1.2.6.min.js" path works if I do:
>      <script type="text/javascript"
> src="./js/jquery-1.2.6.min.js"></script>
>
> I'm missing something conceptually.  Any ideas?



--
Benjamin Eberlei
http://www.beberlei.de