Accessing Java script methods and jQuery through JS Extender or Embedded Resources

Answered
0
0

Hello,

will you please give advise how to (1) write Javascript methods to be found by Call() or Eval() methods from C# and how to (2) use jQuery in JS?

  1. I would like to take advantage of keeping javascript at the controls, not in Resources directory. However, I am not able to get such Java script working when calling by this.Call() or this.Eval() methods (Application.Call | Application.Eval do not help, either) in some cases. A small project with a combo box and a text box is attached…
    When we change the current item in the 1st control (combo box), the script in the context of wisej.web.UserComboBox IS NOT executed, whereas after clicking at the Text box, the appropriate method of a script in the context of wisej.web.TextBox IS normally executed. The context is then changed to Window object (global), which may be caused by using Eval(). I would use Call() but that does not find ANY of my methods. See the browser console.
    I can provide another example with a text box class derived from another class derived from TextBox. The same happens – Java script does not get called. I have attached JS to the final text box control.
  2. When I put Javascript in Resources, jQuery seems to be loaded at the beginning of script ($) but not any more in any function.

Thank you very much!

  • You must to post comments
Best Answer
0
0

To create a javascript function in the context of the widget use:

this.functionName = function() {}

If you just declare the function or assign it to non-scoped variable it’s all global (scoped to window) in Javascript.

See attached modified sample. You can also use VS file nesting extension (https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting) to create really cool self contained control/widgets. Also in the modified sample. It’s not necessary, but it’s useful.

To load jquery simply add it to Default.html.

 

  • You must to post comments
0
0

Hi Libor,

I checked Wisej.UserComboBoxLookup_sample.zip and

  • and there are some configuration errors.
    to run .js files they must be embedded resources
  • add [assembly: WisejResources] in the AssemblyInfo file so that Wisej loads the resources at Javascript timeout.
  •  create a Platform directory where you will create all your javascript files

When you add javascript methods add this.

I send you Wisej.UserComboBoxLookup_sample.zip with the patches

For JQuery I’ll send you a second answer shortly.

Wisej version is 2.2.39

More details:  https://docs.wisej.com/docs/controls/extenders/javascript

Best.

Kevin (ITG)

wisej-usercomboboxlookup_sample_support

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.