-- Fazakas Lajos <[EMAIL PROTECTED]> wrote
(on Friday, 25 July 2008, 11:58 AM +0300):
> Hi!
>
> I have a form where I need to add dojo events to the elements.
>
> I accomplished the following so far:
>
> class Example_Form extends LFM_Form
> {
> public function init()
> {
> Zend_Dojo::enableForm($this);
>
> ........
> $this->addElement('Button', 'foo', array('label' => '+'));
> $this->getView()->dojo()->addOnLoad(
> "function(){
> dojo.connect(dijit.byId('foo'), 'onclick', function(e) {
> foo(e,'bar')
> })
> }");
> ........
> }
> }
>
> This basically adds programmatically an dojo.addOnload function to the
> 'foo' element.
> This is working, but as far as this functionality belongs to the created
> button object it isn't a very "hadsome" solution.
>
> Is there a more elegant way to solve this?
> I'm thinking about something like to be able to pass these params
> somehow to the 'addElement' function.
You can do that already, by relying on the fact that arbitrary element
attributes are used as HTML attributes. :)
$this->addElement('Button', 'foo', array(
'label' => '+',
'onclick' => "function(e) { foo(e, 'bar') }",
));
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/