0

This is practically the first day I step into Cordova in Visual Studio 2015. I have no problem in any sort of coding in C# and MVC but Cordova seems like a total new thing, because I couldn't find anywhere I can write JS code in JS file

In one of my view file, I have one JS file that is auto generated and has the code below

'use strict';
app.homeView = kendo.observable({
onShow: function() {},
afterShow: function() {}
});

// START_CUSTOM_CODE_homeView
// Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes

(function () {
app.homeView.set('title', 'Home');
})();
// END_CUSTOM_CODE_homeView

In this file, I tried many different ways to write my button click event but none of them is working. There is no error in the console. Just no respond.

I wrote the code within the CUSTOM_CODE part, as well as inside the (function () { })();, just nothing work.

Please guide me on the proper of writing JS code in the JS file.

And please let me know if there is any issue in using jQuery in Cordova compare to normal web development

1 Answer 1

1

The code that you have shown is the latest ES6, which has improved significantly from the previous ES5.

app.homeView = kendo.observable({
onShow: function() {},
afterShow: function() {}
});

The snippet above provided by you is how objects are declared.

As most of the browsers are still using ES5, The current solution is to write in ES6 syntax and transpiled into ES5 syntax. Some of the tools that allows you to do that are babel and typescript.

you may wanna visit the following websites to learn more about the syntax.

Typescript

Babel playground

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.