I've tried the suggested solutions but I'm still can't get javascript to show on the client using a helper.
Here's my code :
<?php
class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial
{
public function loginbox()
{
$this->view->headScript()->appendFile('/scripts/js/myfile.js'); // this doesn't work, the file never gets included
$this->view->dojo()->javascriptCaptureStart(); // neigher the content of my javascript function after this
?>
dojo.addOnLoad(function(){
alert("it s working");
});
<? $this->view->dojo()->javascriptCaptureEnd(); ?>
<div id="box" class="box">test</div>
<div id="blockme" class="blockme">
<form method="post" action="/user/login" id="loginform">
<label for="email">Email:</label>
<input type="text" name="email" />
<label for="password"></label>
<input type="password" name="password"/>
<input type="submit" id="loginButton" value="login" >
<div id="loginerrors"></div>
</form>
</div>
<?php
}
}
?>
> > >> Matthew Weier O'Phinney-3 wrote:
> > >> > -- Zladivliba Voskuy <nospampam@hotmail.fr> wrote
> > >> > (on Friday, 07 November 2008, 04:42 PM +0100):
> > >> > >
> > >> > > Is there a way to use dojo in a view helper ? I'm trying to set up a
> > >> > > login box
> > >> > > on all my pages, through a view helper, but with no success so far ;
> > >> I'm
> > >> > > trying
> > >> > > this :
> > >> > >
> > >> > > class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial
> > >> > > {
> > >> > > public function loginbox()
> > >> > > {
> > >> > > $this->dojo()->javascriptCaptureStart(); ?>
> > >> > >
> > >> > > my xhr request ...
> > >> > >
> > >> > > <?php $this->dojo()->javascriptCaptureEnd(); }
> > >> >
> > >> > Use "$this->view->dojo()" -- it's part of the view object attached to
> > >> > the helper.
> > >> >
> > >> > > }
> > >> > > ?>
> > >> > > This of course throws me a Fatal error: Call to undefined method
> > >> > > Zend_View_Helper_Loginbox::dojo()...
> > >> > >
> > >> > > Well, I'm pretty sure it's not the right way to do it but humm, what
> > >> > > would be
> > >> > > the right way ?
> > >> Thanks for your reply. I'm a little bit confused when you say "echo"
> > >> captureStart. What exactly do you mean. i didn't think I was echoing it,
> > >> I
> > >> thought I was just calling it. Do you mean I should leave the catureStart
> > >> call out of the code?
> > >
> > > You had the following constructs:
> > >
> > > <?= $this->dojo()->contentPane()->captureStart(.....); ?>
> > >
> > > "<?=" is equivalent to "<?php echo". Simply change it to "<?".
> >
> > Right. Silly me.
> >
> > I don't know if this is a bug or a "feature". I made the necessary changes
> > and it still did not work. I noticed i was echoing doctype in the layout
> > file. I commented this line out and everything worked. That line didn't
> > affect my outer tabContainer but it definitely affected my inner
> > tabContainer???
>
> If you use a transitional or loose doctype, there are a variety of
> layout features in Dojo that sometimes break (BorderContainer, for
> instance, does not like loose/transitional doctypes). I've found using a
> strict doctype or no doctype usually works.
>
Appelez vos amis de PC à PC -- C'EST GRATUIT Téléchargez Messenger, c'est gratuit !
2008年11月13日星期四
订阅:
博文评论 (Atom)
没有评论:
发表评论