QCubed 1.1.1 + jquery = IE7 and IE8 errors

Login or register to post comments
9 replies [Last post]
Offline
Joined: 03/31/2008

Hello. I hope someone can help me here.

I'm using QCubed 1.1.1 and need to include JQuery 1.4.2 in my project. As soon as I include the JQuery library I get some error when I click on button with AjaxAction when using IE7 or IE8. There is no problem using FF or Chrome.

This is the error IE8 show up

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)
Timestamp: Thu, 1 Jul 2010 14:11:45 UTC
Message: Object doesn't support this property or method
Line: 153
Char: 5
Code: 0
URI: http://192.168.10.79/~brynjar/myproject/assets/_core/js/post.js

Here is the minimal code to replicate the problem.
The form: test.php

<?php
   
require('includes/prepend.inc.php');
    class
Test extends QForm {
        public
$btnTest;
        protected function
Form_Create(){
           
$this->btnTest = new QButton($this);
           
$this->btnTest->Text = 'Click me';
           
$this->btnTest->AddAction(new QClickEvent(), new QAjaxAction('btnTest_Click'));
        }

        public function
btnTest_Click(){}
    }
   
Test::Run('Test');
?>

And the template file: test.tpl.php

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php $this->RenderBegin() ?>
<?php $this->btnTest->Render(); ?>
<?php $this->RenderEnd() ?>
</body>;
</html>

Any ideas? Maybe this it is some local problem. My development environment is Linux and I'm using Apache as web server.

Thanks for your help.
Brynjar

alex94040's picture
Offline
Joined: 11/06/2008

Are you seeing the same errors on the examples page that uses jquery: http://examples.qcu.be/assets/_core/php/examples/advanced_ajax/jquery_ef...

If you're not, take a look at how that page is implemented (you have its source code in your local examples), and model your code after it. QCubed 1.1 already comes with a jQuery distribution.

Offline
Joined: 03/31/2008

The example page is working just fine. I will look into the source code and try to find out what the problem is.

Thank you for your help!

Brynjar

Offline
Joined: 03/31/2008

I just moved the

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

line from the template file to

<?php
$this
->btnTest->AddJavascriptFile(__JQUERY_BASE__);
?>

in the QForm file and now everything is working without errors. The JQuery code I'm using is not in the form of QControl, so I just added the Javascipt file to the button.

Brynjar.

LaCeja's picture
Offline
Joined: 11/04/2009

brynjar, if you move your

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

to your header.inc.php file in the configuration folder, jquery will then be available to all your QCubed programs. Not so critical in QCubed 1.1, but very important in 2.0.

Offline
Joined: 03/31/2008

That is exactly how it was when I got the error. I'm not sure why, but if I include the JQuery library the "QCubed way" (inside the form and not in the head) I don't get any error.

Brynjar.

LaCeja's picture
Offline
Joined: 11/04/2009

It should work, if you put it into your header.inc.php. Does the top of your template file look something like this?

<?php
    $strPageTitle
= QApplication::Translate('Mytable') . ' - ' . $this->mctAcctgcalendars->TitleVerb;
    require(
__CONFIGURATION__ . '/header.inc.php');
?>

Requiring header.inc.php at the top of your template should work. Can you post your header.inc.php file here? It should be pretty short.

Offline
Joined: 03/31/2008

I'm not using the qcubed included header.inc.php in this project (I have my own header file located elsewhere).

But you can copy/paste the example I put in the first post. As soon as I click the button I get error in IE.

Brynjar.

LaCeja's picture
Offline
Joined: 11/04/2009

Interesting. I just tried it on IE7 and it worked. I got no errors. I did have to modify your include of prepend.inc.php, because it's located in the includes/configuration folder on my system. Also, I'm running QCubed 2.0.

In any case, I make extensive use of QAjaxAction and QAjaxControlAction and have never had any problems.

Offline
Joined: 03/31/2008

Ok, I am (still) using version 1.1 But the problem has been solved now :)

Brynjar.