[SOLVED] Any\All jQuery causes Non-Translatable Function Exception: The function 'xxx' could not be translated.

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

[SOLVED] Any\All jQuery causes Non-Translatable Function Exception: The function 'xxx' could not be translated.

Postby TaterJuice » Mon Sep 18, 2017 8:31 am

jQuery works in Simulator, does not work in .js output. Unable to use any jQuery in CSHTML5.Interop.ExecuteJavascript.

Code: Select all

await Interop.LoadJavascriptFile(urlToHostedjQueryDOTjs);
Interop.ExecuteJavascript("$('#myElementID').show();");

Works in Simulator, NonTranslatable function Exception in JS output.

Tried setting noConflict:

Code: Select all

Interop.ExecuteJavascript(@"
    var jQuery = $.noConflict();
    jQuery('#myElementID').show();");

Works in Simulator, NonTranslatable function Exception in JS output.

Tried just using jQuery noConflict without declaring it:

Code: Select all

jQuery('#myElementID').show();

Error jQuery is not defined.

Here is the exception from the output when I try to execute a jQuery function:
JSIL.Browser.js?20179180925:201 Error: The function 'System.Void HTMLButtonTest.KendoUIButton::OnJSLoaded()' could not be translated.
at HTMLButtonTest_KendoUIButton.UntranslatableFunctionInvoked (JSIL.Core.js?20179180925:1228)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.Delegate_Invoke [as onCompleted] (JSIL.Core.js?20179180925:9344)
at Object.INTERNAL_InteropImplementation_LoadJavaScriptFiles (CSharpXamlForHtml5.js?20179180925:7548)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.$l$gc__DisplayClass7_$lLoadJavaScriptFiles$gb__5 (CSharpXamlForHtml5.js?20179180925:7614)
at HTMLScriptElement.Delegate_Invoke (JSIL.Core.js?20179180925:9344)
JSIL.Browser.WarningService.write @ JSIL.Browser.js?20179180925:201


JSIL.Browser.js?20179180925:199 Error: The function 'System.Void HTMLButtonTest.KendoUIButton::OnJSLoaded()' could not be translated.
at HTMLButtonTest_KendoUIButton.UntranslatableFunctionInvoked (JSIL.Core.js?20179180925:1228)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.Delegate_Invoke [as onCompleted] (JSIL.Core.js?20179180925:9344)
at Object.INTERNAL_InteropImplementation_LoadJavaScriptFiles (CSharpXamlForHtml5.js?20179180925:7548)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.$l$gc__DisplayClass7_$lLoadJavaScriptFiles$gb__5 (CSharpXamlForHtml5.js?20179180925:7614)
at HTMLScriptElement.Delegate_Invoke (JSIL.Core.js?20179180925:9344)
JSIL.Browser.WarningService.write @ JSIL.Browser.js?20179180925:199


JSIL.Host.js?20179180925:240 Uncaught Error: The function 'System.Void HTMLButtonTest.KendoUIButton::OnJSLoaded()' could not be translated.
at HTMLButtonTest_KendoUIButton.UntranslatableFunctionInvoked (JSIL.Core.js?20179180925:1228)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.Delegate_Invoke [as onCompleted] (JSIL.Core.js?20179180925:9344)
at Object.INTERNAL_InteropImplementation_LoadJavaScriptFiles (CSharpXamlForHtml5.js?20179180925:7548)
at CSHTML5_INTERNAL_InteropImplementation_$l$gc__DisplayClass7.$l$gc__DisplayClass7_$lLoadJavaScriptFiles$gb__5 (CSharpXamlForHtml5.js?20179180925:7614)
at HTMLScriptElement.Delegate_Invoke (JSIL.Core.js?20179180925:9344)

JS-Support @Userware
Site Admin
Posts: 1142
Joined: Tue Apr 08, 2014 3:42 pm

Re: Any\All jQuery causes Non-Translatable Function Exception: The function 'xxx' could not be translated.

Postby JS-Support @Userware » Wed Sep 20, 2017 2:59 am

Hi,

"$" is a reserved keyword for the "ExecuteJavaScript" method. It is used to pass arguments to the string literal (see the ExecuteJavaScript documentation).

If you want to use jQuery, you need to use "window.jQuery" instead of "$". For example, you can call jQuery.noConflict() instead of $.noConflict()

Please have a look at the source code of the jQuery Ajax extension for CSHTML5 to see an example of loading and using jQuery.

Thanks.
Regards,
JS-Support

TaterJuice
Posts: 147
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: Any\All jQuery causes Non-Translatable Function Exception: The function 'xxx' could not be translated.

Postby TaterJuice » Wed Sep 20, 2017 4:28 pm

JS-Support wrote:Hi,

"$" is a reserved keyword for the "ExecuteJavaScript" method. It is used to pass arguments to the string literal (see the ExecuteJavaScript documentation).

If you want to use jQuery, you need to use "window.jQuery" instead of "$". For example, you can call jQuery.noConflict() instead of $.noConflict()

Please have a look at the source code of the jQuery Ajax extension for CSHTML5 to see an example of loading and using jQuery.

Thanks.
Regards,
JS-Support


Perfect, thank you!
(Please feel free to move this to the Support forum, from bug reports - my apologies!)


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 4 guests

 

 

cron