Mar 29, 2011, 3:59 PM
UserControl and Javascript - The Javascript method defined in the UserControl is "not found"?
hey,
I have a UserControl in which i define a simple Javascript function:
Before I post a complete code example, anyone understands this? Must the Javascript functions be declared somewhere special?
-- update --
I removed the "window.opener" and then it started working better.
I have a UserControl in which i define a simple Javascript function:
<script language="javascript" type="text/javascript">
function CheckForCallback(success, errorMsg, customerId) {
if (typeof window.opener.CustomerReportCallback == 'function') {
window.opener.CustomerReportCallback(success, errorMsg, customerId);
}
else alert('No method implemented');
}
</script>
This function, "CheckForCallback" is called from the same UserControl in a Click listener like this:<ext:FormPanel ID="FormPanel1" runat="server" Height="330" Width="460" Title="Kundinformation" Header="true" Padding="5" MonitorResize="true">
<BottomBar runat="server">
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:ToolbarFill ID="ToolbarFill1" runat="server" />
<ext:Button ID="btnSaveCreateCustomer" Icon="Disk" Text="Spara" runat="server" >
<Listeners>
<Click Handler="CheckForCallBack(1 , '', 0);" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</BottomBar>
...
When trying this in Chrome I get the following Javascript error:
Uncaught ReferenceError: CheckForCallBack is not defined
Customers.aspx:24 Uncaught ReferenceError: CheckForCallBack is not defined
Ext.form.FormPanel.bbar.items.listeners.click.fnCu stomers.aspx:24
h.Event.fireext.axd:7
Ext.override.fireEventext.axd:55
Customers.aspx:24 Uncaught ReferenceError: CheckForCallBack is not defined
Ext.form.FormPanel.bbar.items.listeners.click.fnCu stomers.aspx:24
h.Event.fireext.axd:7
Ext.override.fireEventext.axd:55
-- update --
I removed the "window.opener" and then it started working better.
Last edited by wagger; Mar 29, 2011 at 4:57 PM.