PDA

View Full Version : [CLOSED] [#735] Fn & Handler : Call both



matrixwebtech
Feb 22, 2015, 4:03 PM
Hi
I have a code like bellow

Html.X().Viewport()
.Listeners(l => { l.AfterRender.Fn = "setControlState"; l.AfterRender.Handler = "getCookies()"; })
and I expect the both function call after viewport AfterRender but not called.
If I declare only Fn or only Handler then called as expected .
I try bellow to call both function but a javascript error occurred

Html.X().Viewport()
.Listeners(l => { l.AfterRender.Fn = "setControlState;getCookies"; })
I also try

.Listeners(l => { l.AfterRender.Fn = "setControlState"; l.AfterRender.Fn = "getCookies"; })
In that case second Fn only works.
I again try

.Listeners(l => { l.AfterRender.Handler = "setControlState();getCookies()"; })
then both function called.
So is there any way to avoid Handler to call both functions with Fn.

geoffrey.mcgill
Feb 22, 2015, 4:33 PM
Hello,


So is there any way to avoid Handler to call both functions with Fn.

Please use only .Fn or .Handler, but not both. Unexpected results may occur. There might be a race condition, or one might fire and the other might not. Unexpected results.

geoffrey.mcgill
Feb 22, 2015, 4:35 PM
This actually a scenario where we should throw a Compilation error, or Exception. If both .Fn and .Handler are set on the same event config.

matrixwebtech
Feb 22, 2015, 4:50 PM
Hi
Thanks for reply.
.Listeners(l => { l.AfterRender.Handler = "setControlState();getCookies()"; }) working fine do I go with this.can I do this same thing with Fn ,bellow code is generate java script error,what I doing wrong here?

Html.X().Viewport()
.Listeners(l => { l.AfterRender.Fn = "setControlState;getCookies"; })

geoffrey.mcgill
Feb 22, 2015, 5:46 PM
The .Fn property can accept one function name.

Daniil
Feb 25, 2015, 10:11 AM
This actually a scenario where we should throw a Compilation error, or Exception. If both .Fn and .Handler are set on the same event config.

Created an Issue - Listener and JFunction: using Fn and Handler at the same time should throw an Exception (https://github.com/extnet/Ext.NET/issues/735).

Done in the revision 6390 (trunk). It goes to 3.2.0.

For example, this example throws Listener: the Fn and Handler must not be used at the same time. The Listener Owner's ID: Button1, type: Ext.Net.Button.

Example

<%@ Page Language="C#" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v3 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button ID="Button1" runat="server" Text="Click me">
<Listeners>
<Click Handler="alert('Handler!');" Fn="function() { alert('Fn'); }" />
</Listeners>
</ext:Button>
</form>
</body>
</html>