PDA

View Full Version : [FIXED] [V0.6] Button AjaxEvent Success



Timothy
Sep 11, 2008, 1:15 PM
Question, should the Success property of the Click AjaxEvent for Ext:Button not fire after the OnEvent returns? As of right now, I have an alert in the Success and it fires before my code behind does :)

Not sure if this is intended or a bug.

Cheers,
Timothy

Vladimir
Sep 11, 2008, 1:47 PM
Hi Timothy,

Can you post full source code of example? The Success handler must be fired after server side code execution

Timothy
Sep 11, 2008, 5:46 PM
<%@ 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">
<script runat="server">
protected void btnDemo_Click(object sender, AjaxEventArgs e)
{
lblTest.Text = "Life is over ...";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
<ext:ScriptManager ID="ScriptManager2" runat="server" Theme="Gray" />
<ext:Button ID="btnDemo" runat="server" AutoPostBack="False" Text="Demo">
<AjaxEvents>
<Click OnEvent="btnDemo_Click" Success="alert('Timothy wuz here')" />
</AjaxEvents>
</ext:Button>
<ext:Label ID="lblTest" runat="server" Text="Waiting ..." />
</form>
</body>
</html>


Cheers,
Timothy

Vladimir
Sep 11, 2008, 5:56 PM
Hi Timothy,

The Success handler should be function



<Click OnEvent="btnDemo_Click" Success="function(){alert('Timothy wuz here')}" />

Timothy
Sep 11, 2008, 6:05 PM
Oops, crap!

Thanks vlad for pointing that out :)

Can we get a SuccessFn or something so we don't need to? Lazy me I know ...

Cheers,
Timothy

geoffrey.mcgill
Sep 14, 2008, 8:40 AM
Hi Timothy,

We're changing the "Failure" and "Success" properties of the AjaxEvent to automatically wrap the value in a function template. Two parameters will be passed into the function: "response" and "options".

The following sample demonstrates setting the "Success" property and below shows what will be rendered to the client.

Example


<Click OnEvent="btnDemo_Click" Success="alert('Timothy wuz here')" />


function(response, options) { alert('Timothy wuz here') }
The code should be committed to svn before the end of the day and will be available with v0.6.

Hope this helps.

Timothy
Sep 14, 2008, 11:16 AM
Great, thanks Geoffrey!