PDA

View Full Version : [FIXED] [V0.8.0] Bug in Coolite.AjaxEvent



abertram
Jan 16, 2009, 2:03 PM
in the beforerequest listener, there's a line that throws an exception:


o.url = forms[0].dom.action || Coolite.Ext.Url || window.location.href;
o.url = forms[0].action || Coolite.Ext.Url || window.location.href;

it should read:


o.url = forms[0].action || Coolite.Ext.Url || window.location.href; o.url = forms[0].action || Coolite.Ext.Url || window.location.href;

popped up on Click AjaxEvent on a Button in a GridPanel with Type=Load

geoffrey.mcgill
Jan 16, 2009, 4:33 PM
Hi abertram,

Nice find. I'm investigating and will fix immediately.


Thanks for bringing this to our attention.

jeybonnet
Jan 18, 2009, 4:43 PM
hi

same here when event click on Button is Type="Load" and form has not action property defined.

When I execute I have an error in Coolite.axd on forms[0].dom.action : dom is undefined


if (Ext.isEmpty(o.form) && Ext.isEmpty(o.url)) {
var forms = Ext.select("form").elements;

if (forms.length > 0) {
if (o.type == "submit") {
o.form = Ext.get(forms[0]);
} else {
o.url = forms[0].dom.action || Coolite.Ext.Url || window.location.href;
}
}
}

Vladimir
Jan 23, 2009, 10:09 AM
Hi guys,

Can you post sample code which reproduces the error?

Here is my test case which works fine:



<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<title></title>

<script runat="server">
protected void Button1Click(object sender, AjaxEventArgs e)
{
Button1.AddScript("alert('clicked');");
}
</script>
</head>
<body>
<form>
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />

<ext:Button ID="Button1" runat="server" Text="AjaxEvent">
<AjaxEvents>
<Click OnEvent="Button1Click" Type="Load"></Click>
</AjaxEvents>
</ext:Button>
</form>
</body>
</html>

abertram
Jan 23, 2009, 11:29 AM
Hi Vlad,

I don't quite recall where this cropped up (i've since fixed the js on my end), but i can point out why the error occurs. Take a look at the beforerequest handler of the Coolite.AjaxEvent class, at this block:


1:                            if (Ext.isEmpty(o.form) &amp;&amp; Ext.isEmpty(o.url)) {
2:                                var forms = Ext.select("form").elements;
3:                                if (forms.length > 0) {
4:                                    if (o.type == "submit") {
5:                                        o.form = Ext.get(forms[0]);
6:                                    } else {
7:                                        o.url = forms[0].dom.action || Coolite.Ext.Url || window.location.href;
8:                                    }
9:                                }
10:                            }

It's at line 1520 of debug version of coolite-core.js of the 0.7.0 release, if that still means something.

Line 2 sticks an array of native DOM element (not wrapped) into forms, but than in line 7, the code tries to reference as if it were an Ext.Element. Since it's not and the dom property is not defined on a form element, it throws.

You just have to change line 7 to read:


o.url = forms[0].action || Coolite.Ext.Url || window.location.href;

HTH

Alex

Vladimir
Jan 23, 2009, 11:52 AM
Hi Alex,

Thanks for clarifications. It seems this code is fixed already.