QFormBase error in adding Javascript file on Ajax call

thread: 3 messages  |  last: a year ago  |  started: tuesday, march 3, 2009, 11:24 am pst


#1  |  Sebastien Dube (Guelph, Ontario) Canada
Tuesday, March 3, 2009, 11:24 AM PST

In QFormBase.class.php around line 433 when adding the javascript .js files. The resulting command tag looks like this

qc.loadJavaScriptFile("....../js/_core/listbox.js", function() {qc.regCA(new Array("c5","pnlClientsPanel","pnlClientsList","c8","c9","c10",
"pnlEditorPanel","pnlClientEditPanel",
......
)); alertPanel('alert Message'); });

Which in fact only execute loadJavaScriptFile with 2 parameters while it requires only one.

I've changed the code in QFormBase.class.php from:

foreach ($strJavaScriptToAddArray as $strScript) {
                if ($strCommands)
                    $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", function() {' . $strCommands . '}); ';
                else
                    $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", null); ';
            }

to

foreach ($strJavaScriptToAddArray as $strScript) {
                if ($strCommands)
                    $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '"); ' . $strCommands ;
                else
                    $strCommands = 'qc.loadJavaScriptFile("' . $strScript . '", null); ';
            }

And now it's working properly in my case ... and this case. I'll will inform you if i find anything else.

#2  |  Sebastien Dube (Guelph, Ontario) Canada
Tuesday, March 3, 2009, 11:35 AM PST

Well i didn't mention the fact that the issue that i was having is the

ExecuteJavascript(alertPanel(\'alert Message\');)

was not executed on the first load of a panel after an Ajax action.

Here's the initial situation

I have a form that display a menu in a div. In another div, i load a QPanel depending on the menu item selected.

My menu use a QLinkButton but also tried using a QButton.

On the first load of the page, the Qpanel is empty. In fact i render a “dummy” QPanel like

$this->pnlMain = new QPanel($this);
$this->pnlMain->AutoRenderChildren = true;

I've tried putting a dummy text like “click on the menu”.

When the user click a menu item, i do a QAjaxAction:

$this->pnlMain->RemoveChildControls(true);
$currpanel = new my_panel($this->pnlMain);
QApplication::ExecuteJavaScript('alert(\'my_panel\')');

As guessed, the javascript IS NOT executed, BUT if i click again the same menu item, the script IS executed.



After a couple hours of research i came to realise that the problem occured only of the my_panel include a listbox (in the my_panel.class.php not necessarly in the template file).

After examining the response and the eval() of the command, i realized that loadJavaScriptFile was executed with 2 parmaeters.

I also posted a similar POST on the QCubed website forum. I hope MikeHo will be back soon and that little war QCubed and QCodo will be over otherwise i'll just find another framework and invite people to do the same.

Where in the world is MikeHo??!!!
:-)

#3  |  Muthu kumar (India) India
Thursday, June 17, 2010, 1:55 AM PDT

in pageload Execute some javascript or want some alert messeages

do the steps:

protected function Form_Exit() {          
           
           $this->txtfield->Focus();
           QApplication::ExecuteJavaScript(“alert('hi')”);
       }

its working fine



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.