got error in hello world itself

Discuss anything that's related to the Raxan framework

Re: got error in hello world itself

Postby finaxis » Sun Mar 18, 2012 8:05 pm

hello Raymond,
$a = Please let know how to change the content of a div recursively preferably with async callbacks.
$b = how to use xt-autoupdate on the fly. it shows up 'as is' in html source in the browser.(when the div is loaded via ajax).

something like this :
Code: Select all
function _load(){ $this->messageus->bind('click',array('callback' => '.contactus'));}

function contactus(){
$contact = $this->getView('contactus.php','#myform');
$this->mains->html($contact);
$this->submitMyMessage->bind('click',array('callback' => '.submit1')); }//this callback isn't working but 'click' on 'submitMyMessage' refreshes the page silently

function submit1()
{
$watch = $this->getView('contactus.php', '#thankyou');
$this->mains->html($watch);
}


I've tried marking xt-bind('click,submit1") on the '#submitMyMessage' and it show up 'as is' in source.

many thanks for all your efforts.
Finaxis
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

Re: got error in hello world itself

Postby raymond » Mon Mar 19, 2012 6:35 am

Hi,

The reason why the events are not being triggered not defined in the _init, _authorize, _*Views or load events. Your events must be defined in one of these methods so that they can be invoked when the page is being processed

Page event order:

_init
_authorize
_indexView
_load
{custom events}
_prerender
_postrender
_reply
_destroy

You might have to modify your code to use page views:

Code: Select all
function _indexView(){
    $this->appendView('main.php');
    $this->messageus->bind('click',array('callback' => '.contactus'));
}

function _contactformView() {
    $this->appendView('contactus.php','#myform');
    $this->submitMyMessage->bind('click',array('callback' => '.submit1'));
}

function _thankyouView() {
    $this->appendView('contactus.php', '#thankyou');
}

function contactus($e){
    // ..do something here...
    $this->redirectToView('contactform'); // redirect to contact form
}


function submit1($e) {
    // ...do something here...
    $this->redirectToView('thankyou');  // redirect to thank you view
}
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: got error in hello world itself

Postby finaxis » Mon Mar 19, 2012 6:16 pm

Simply works!

However, if I use '#click' then the second callback fails.
Code: Select all
function _indexView(){
    $this->appendView('main.php');
    $this->messageus->bind('click',array('callback' => '.contactus')); //#click here, causes the second callback (.submit1) to fail
}


Is there any way to go 'async'?

I think I'll be needing your support till I get the hack of this beautiful framework. hope that's not too bore for you.

thanks and Regards
Finaxis.
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

Re: got error in hello world itself

Postby raymond » Tue Mar 20, 2012 3:39 pm

Hi,

See my comments below:

finaxis wrote:However, if I use '#click' then the second callback fails.


Did it redirect to the contact form when you use #click?

Is there any way to go 'async'?


By 'async' you mean loading the contact form without reloading or redirecting the page? If so, then you can dynamically load the contact form when the contact us button is click. Here's an example:

Code: Select all
function _indexView(){
    $this->appendView('main.php');
    $this->messageus->bind('click',array('callback' => '.contactus'));
    // delegate the #submitMyMessage click event when the form is loaded
    $this->findById('contactFormContainer')->delegate('#submitMyMessage click',array('callback' => '.submit1'));
}

function contactus($e){
    // ..do something here...
    $div = $this->findById('contactFormContainer');
    // append the contact form to the container
    $div->appendView('contactus.php','#myform');
    $div->updateClient(); // update the client
}


I think I'll be needing your support till I get the hack of this beautiful framework. hope that's not too bore for you.


It's not a problem. I'm here to support you in the best way I can.

Keep up the good work and best regards,
__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: got error in hello world itself

Postby finaxis » Tue Mar 20, 2012 7:58 pm

Your support is a great boost Raymond. Thanks.
Actually, m trying to load consecutive views with #click like
$a (does not work) = indexview '#click' -> contactus '#click' -> thankyou. (how to make it work ?)

$b (works) = indexview 'click' -> contactus '#click' -> thankyou.

(-> is used for flow , no php/js meant)


Other errors:
$a = $this->messageus->bind('click',array('callback' => '.contactus','view' => 'contact')); // when used , does not perform the function statements but directly delivers the view; '.contactus' is ignored but the view is loaded. However, if '.contactus' has some errors , it shows up.

$b = m directly replacing the (master content) in the template by these (contact, thankyou) views . index view is a tabstrip. when I update any other thing in master template the whole tabstrip strips down and reveal all the content.

Thanks and Regards,
Finaxis
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

Re: got error in hello world itself

Postby raymond » Wed Mar 21, 2012 5:19 am

Hi,

I've attached an example showing how to load a view after an ajax click event (#click).

example.zip
(993 Bytes) Downloaded 140 times


Here's the code:

index.php
Code: Select all
<?php

require_once 'raxan/pdi/autostart.php';

class IndexPage extends RaxanWebPage {

   protected function _indexView() {
      // load main view
      $this->appendView('myviews.php','#main');
   }
   
   protected function _contactView() {
      $this->appendView('myviews.php','#contactform');
   }   

   protected function _thankyouView() {
      $this->appendView('myviews.php','#thankyou');
   }   
   
   // contactus event handler
   protected function contactus($e) {
      // do something there
      $this->redirectToView('contact');
   }

   // saveform event handler
   protected function saveForm($e) {
      $name = $this->post->textVal('contactname');
      if (empty($name)) c()->alert('Please enter a valid name');
      else {
         // do something here
         $this->redirectToView('thankyou');
      }
   }

}

?>


views/myviews.php
Code: Select all
<div id="main">
   <form>
      <h3>Show Contact Form</h3>
      <button xt-bind="#click,contactus">Load form</button>
   </form>   
</div>


<div id="contactform">
   <form>
       <h3>Contact Form</h3>
       Name <input type="text" name="contactname" />
      <button  type="submit" xt-bind="#click,saveForm">Submit</button>
   </form>
</div>


<div id="thankyou">
   <h3>Thank you</h3>
   <a href="index.php">Back to main</a>
</div>


Give it try and let me know if you got it to work.

Best regards,
__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: got error in hello world itself

Postby finaxis » Wed Mar 21, 2012 9:07 pm

Appreciate your efforts but results are still the same. The page gets refreshed on both clicks and the address bar shows "localhost...site/index.php?vu=contact" and "localhost...site/index.php?vu=thankyou".

based on your previous reply, my workout (below), the page gets refreshed on the first click (loading the form) and thankyou page was async (no refresh).
both the times url was "localhost...site/?vu=contact" (no index.php) -- just trying to keep it "localhost...site/" both the times.

Code: Select all
**********index.php*************
function _indexView()
      {
         $this->appendView('index.view.php'); // this is plain html (tabstrip) loading into "master-content"
                        $this->messageus->bind('click', array('view' => 'contact')); // anchor placed on the master template (using #click here causes the submitMessage to fail)
               }

function _contactView()
      {
         //do something here
         $this->appendView('contactus.php', '#contactus');
         $this->submitMessage->bind('#click', array('view' => 'thankyou')); // this fails with #click above
         
      }

function _thankyouView()
      {
         $this->appendView('contactus.php', '#thankyou');
      }

***********contactus.php**********
<div id="contactus"
   <form action="" id="ContactForm"
      <textarea name="message" id="message1" cols="40" rows="3" class="expand"></textarea> <br/> <br/
      <input type="submit" value ="Send Message" id="submitMessage" xt-bind="#click,_thankyouView">
   </form>

<div id="thankyou">
   <h3>Thank You</h3>
</div>


its ok like this but A wizard-like effect can be created .
Thanks and Regards,
Finaxis
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

Re: got error in hello world itself

Postby raymond » Fri Mar 23, 2012 3:34 am

Hi,

based on your previous reply, my workout (below), the page gets refreshed on the first click (loading the form) and thankyou page was async (no refresh).
both the times url was "localhost...site/?vu=contact" (no index.php) -- just trying to keep it "localhost...site/" both the times.


Ah! I see what you're looking for.

I've put together an example showing how it can be done. See the attached file:

contactus.zip
(1.44 KiB) Downloaded 140 times


Here's the content of the file:
Code: Select all
<?php

require_once 'raxan/pdi/autostart.php';

class IndexPage extends RaxanWebPage {

   protected function _indexView() {
      // load main view
      $this->appendView('index.view.php');
      $this->delegate('#contactbtn','#click','.contactUs'); // delegate contactbtn
      $this->delegate('#savecontact','#click','.saveForm'); // delegate savecontact
   }
      
   // contactus event handler
   protected function contactUs($e) {
      // update the container with the contact form
      $elm = $this->findById('contactcontainer')->html('');
      $elm->appendView('contact.views.php','#contactform');
      $elm->updateClient()
         ->client->hide()->fadeIn(); // fadein new updates
   }

   // saveform event handler
   protected function saveForm($e) {
      $name = $this->post->textVal('contactname');
      if (empty($name)) c()->alert('Please enter a valid name');
      else {
         // update the container with the thank you message
         $elm = $this->findById('contactcontainer')->html('');
         $elm->appendView('contact.views.php','#thankyou');         
         $elm->updateClient()
            ->client->hide()->fadeIn(); // fadein new updates
         // set contact name   
         $this->findById('contactName')->text($name);      
      }
   }

}

?>


index.view.php
Code: Select all
<?php defined('RAXANPDI')||die; ?>

<div id="contactcontainer">
   <form>
      <h3>Show Contact Form</h3>
      <button id="contactbtn">Load form</button>
   </form>   
</div>


contactus.views.php
Code: Select all
<?php defined('RAXANPDI')||die; ?>

<div id="contactform">
   <form>
       <h3>Contact Form</h3>
       Name <input type="text" name="contactname" />
      <button id="savecontact" type="submit" xt-bind="#click,saveForm">Submit</button>
   </form>
</div>


<div id="thankyou">
   <h3>Thank you</h3>
   <p>
      Hi <span id="contactName"></span>,<br/>
      Thank you for contacting us.
   </p>   
   <p><a href="index.php">Back to main</a></p>
</div>



Best regards,
__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: got error in hello world itself

Postby finaxis » Fri Mar 23, 2012 6:06 pm

BINGOOOOO :D
Its GREAT !!!! next time I'll try to ask right in the first place.

Thanks and Regards,
Finaxis.
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

Re: got error in hello world itself

Postby finaxis » Wed Mar 28, 2012 2:45 am

Woops! :o ,
$postBackToken and auto toggle does not work when contact form loads with ajax

$a = $this->delegate('#savecontact','#click','.saveForm'); // works perfect but how to autoToggle/autoDisable submit button during the save process.

$b = can not load dynamic content like $postBackToken via ajax.

$c = Is there any way to load a picture in $this->flashmsg or show the count down timer till server responds. My script is taking around 10 secs to respond. I tried loading the script (togglecontent) via _load / _init and also directly on master template but the browser does wanna listen.What to do?

Raxan is fun to use. just started enjoying it.

Thanks and Regards,
Finaxis
finaxis
 
Posts: 28
Joined: Thu Feb 16, 2012 1:17 pm

PreviousNext

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron