Exemplo n.º 1
0
 function actionDefault()
 {
     // create a form with a span and a button
     $form = new YDForm('myform');
     $form->addElement('span', 'myspanresult', ' ', array('style' => 'BACKGROUND-COLOR:#ccccff'));
     $form->addElement('button', 'mybutton', 'Get version');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // create custom effects for waiting message
     $onStart = new YDAjaxEffect('', 'opacity', 'hide()', 0);
     $onShow = new YDAjaxEffect('', 'opacity', 'custom(0,1)', 0);
     $onHide = new YDAjaxEffect('', 'opacity', "toggle()");
     // use waiting message with custom effects
     $this->ajax->useWaitingMessage("<h2>&nbsp; Please wait ... &nbsp;<\\/h2>", array(), $onStart, $onShow, $onHide);
     // to use default waiting message just try:
     // $this->ajax->useWaitingMessage();
     // register element mybutton (mybutton will be assigned with 'getversion' call in the client side)
     $this->ajax->addEvent('mybutton', array(&$this, 'getversion'));
     // process ajax events
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This example demonstrates the waiting message with custom parameters');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }
 function actionDefault()
 {
     // create a form with a 2 autocompleters and a simple text element
     $form = new YDForm('myform');
     $form->addElement('autocompleter', 'arg1', 'Country with standard style:', '', array(&$this, 'getCountry'));
     $form->addElement('text', 'arg2', 'Just a simple text box without autocompleter');
     $form->addElement('autocompleter', 'arg3', 'Country with custom style:', array('style' => 'width:300px; background-color:#CCFFFF;'), array(&$this, 'getCountry'));
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // process events added
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'Just start typing a coutry name in the box to see the effect');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display();
 }
 function actionDefault()
 {
     // create a form with a span and a button
     $form = new YDForm('myform');
     $form->addElement('span', 'myspanresult', '&nbsp;', array('style' => 'BACKGROUND-COLOR:#ccccff'));
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // register custom function
     $this->ajax->addEvent('customFunction()', array(&$this, 'getversion'));
     // process ajax events
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This is a simple ajax example');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display();
 }
Exemplo n.º 4
0
 function actionDefault()
 {
     // create a form with a span and a button
     $form = new YDForm('myform');
     $form->addElement('span', 'myspanresult', '&nbsp;', array('style' => 'BACKGROUND-COLOR:#ccccff'));
     $form->addElement('button', 'mybutton', 'Get YDFramework version');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // register element mybutton (mybutton will be assigned with 'getversion' call in the client side)
     $this->ajax->addEvent('mybutton', array(&$this, 'getversion'));
     // process ajax events
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This is a simple ajax example');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }
 function actionDefault()
 {
     // create a form with a span and two buttons
     $form = new YDForm('myform');
     $form->addElement('span', 'myspanresult', '&nbsp;', array('style' => 'WIDTH:350px;BACKGROUND-COLOR:#ccccff'));
     $form->addElement('button', 'mybutton', 'Get YDFramework version');
     $form->addElement('button', 'mybutton2', 'Get time');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // register element mybutton with event result and fixed argument '1' and mybutton2 with event 'result' with argument 2
     $this->ajax->addEvent('mybutton', array(&$this, 'result'), 1);
     $this->ajax->addEvent('mybutton2', array(&$this, 'result'), 2);
     // process events added
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This is a two buttons example with a different event assigned for each one');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }
 function actionDefault()
 {
     // create a form with a 2 texts, a button and a span for result
     $form = new YDForm('myform');
     $form->addElement('text', 'arg1', 'X:');
     $form->addElement('text', 'arg2', 'Y:');
     $form->addElement('button', 'mybutton', 'Sum');
     $form->addElement('span', 'myspanresult', '&nbsp;');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // assign 'mybutton' with 'compute' call with dynamic values from form elements 'arg1' and 'arg2'
     $this->ajax->addEvent('mybutton', array(&$this, 'compute'), array('arg1', 'arg2'));
     // process events added
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This a calculator example. Fill X and Y');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }
 function actionDefault()
 {
     // create a form with a 2 texts, a select to choose operation, a button and a span for result
     $form = new YDForm('myform');
     $form->addElement('text', 'arg1', 'X:');
     $form->addElement('select', 'operation', 'Operation', array(), array(0 => '+', '-', 'x', '/'));
     $form->addElement('text', 'arg2', 'Y:');
     $form->addElement('span', 'myspanresult', '&nbsp;');
     $form->addElement('button', 'mybutton', 'Calc');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // assign 'mybutton' with 'compute' call with dynamic values from form elements 'arg1', 'arg2' and 'operation'
     $this->ajax->addEvent('mybutton', array(&$this, 'compute'), array('arg1', 'arg2', 'operation'));
     // process events added
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This a dynamic calculator example (you can choose operation)');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }
 function actionDefault()
 {
     // create a form with a span and a button
     $form = new YDForm('myform');
     $form->addElement('span', 'myspanresult', '&nbsp;', array('style' => 'WIDTH:350px;BACKGROUND-COLOR:#ccccff'));
     $form->addElement('button', 'mybutton', 'Get YDFramework version');
     // create ajax object
     $this->ajax = new YDAjax($this->tpl, $form);
     // register element mybutton (mybutton will be assigned with 'getversion' call in the client side)
     $this->ajax->addEvent('mybutton', array(&$this, 'getversion'));
     // add confirmation to mybutton call
     $this->ajax->addConfirmation('mybutton', 'Are you shure you want to get ydf version?');
     // create an alias (submitCall). you can see a new function submitCall() is js client code
     // note that, addAlias is defined AFTER addConfirmation, then submitCall() will have confirmation too
     // alias BEFORE addConfirmation will assign submitCall() with a clean event
     $this->ajax->addAlias('mybutton', 'submitCall()');
     // process ajax events
     $this->ajax->processEvents();
     // assign form and display template
     $this->tpl->assign('title', 'This demonstrates how to add confirmations and aliases');
     $this->tpl->assign('form', $form->tohtml());
     $this->tpl->display('general');
 }