[SOLVED] QAjaxAction not working

I am trying to show a modal when a user clicks a button, but unfortunately, it seems that QAjaxAction is somewhat not working. When I change it to a QJavaScriptAAction and throw up an alert box, it does work, thus showing QClickEvent is getting triggered. Also the modal shows up when set Display and AutoOpen = true.

 

<?php require_once 'admin/qcubed.inc.php';


class Index extends QForm{


    protected $btnUpdateArray = array(5);

    protected $strUpdateArray;

    protected $intNumberOfUpdates;

    protected $strUpdate;

    protected $dlgUpdate;

    protected $btnAllUpdates;


    protected function Form_Create(){

        $this->dlgUpdate = new QDialog($this);

        $this->dlgUpdate->Title = "Hello World";

        $this->dlgUpdate->Text = "Lets see if this works";

        $this->dlgUpdate->Modal = true;

        $this->dlgUpdate->AutoOpen = false;

        $this->dlgUpdate->Display = false;


        $this->btnAllUpdates = new QButton($this);

        $this->btnAllUpdates->Text = "Show All Updates";

        $this->btnAllUpdates->AddAction(new QClickEvent(), new QAjaxAction('showUpdatesBox'));


        $this->strUpdateArray = Siteupdates::LoadAll(QQ::Clause(

            QQ::OrderBy(QQN::Siteupdates()->Id, false),

            QQ::LimitInfo(5)

        ));

        if($this->strUpdateArray!= null){

            $this->intNumberOfUpdates = Siteupdates::CountAll();

            if($this->intNumberOfUpdates>5){

                $this->intNumberOfUpdates = 5;

            }

            $i = 0;

            foreach($this->strUpdateArray as $this->strUpdate){

                $this->btnUpdateArray[$i] = new QButton($this);

                $this->btnUpdateArray[$i]->Text = $this->strUpdate->Title;

                $this->btnUpdateArray[$i]->CssClass = "btn btn-link";

                $this->btnUpdateArray[$i]->CausesValidation = false;

                $this->btnUpdateArray[$i]->AddAction(new QClickEvent(), new QAjaxAction('showUpdatesBox'));

                $i++;

            }

        }

    }


    protected function showUpdatesBox($strFormId, $strControlId, $strParameter){

        $this->dlgUpdate->Open();

    }

}

Index::Run('Index');
Login or Register to comment on this topic.
Re [QAjaxAction not working]:

Solved. The problem was with RenderBegin() in tpl.php file. I wrote it at the beginning of the file, but it had a multiple form declarations in HTML that were posing the problem. Moved it just before addin the buttons, it worked :-)

Permalink
Login or Register to comment on this topic.