Application object
Previously we have seen how to initialize the mobile application and set the transition configuration option. Transition is just one example from many global configurations that we can perform while instantiating a Kendo UI Mobile application. Let's explore some of the functionalities we can achieve using the Application object.
The Initial view
Using the initial configuration option, we can set the initial view to be displayed after the app is initialized:
new kendo.mobile.Application($(document.body), { initial: "intialViewID" });
Loading text
Using the loading configuration we can set the text shown when the loading animation is displayed. If this value is set to false
, loading animation will not be displayed. The text needs to be wrapped in <h1
> </h1
> tags:
new kendo.mobile.Application($(document.body), { loading: "<h1>Loading...</h1>" });
Forcing platform
As we know, Kendo renders platform-specific UI. However, it provides the option to force a particular platform's look and feel on all the platforms using the platform configuration option:
<script> new kendo.mobile.Application($(document.body), { platform: "android" }); </script>
Even though this option is available, using a Flat UI theme is the recommended way of building apps with a consistent look and feel across platforms.
Hiding and showing the loading animation
The Application object helps to show and hide loading animation programmatically. The showLoading()
method of the Application object displays the built-in loading animation of your Kendo Mobile app:
var application = new kendo.mobile.Application();
application.showLoading();
Using the hideLoading()
method of the Application object, we can hide the loading animation.
var application = new kendo.mobile.Application();
application.hideLoading();
Getting a reference of the current view
When we develop a fully functional application, typically we will encounter a scenario where we need to get a reference of the currently displayed view in our JavaScript code.
The view()
method of the Application object provides the reference of the currently displayed view object:
var application = new kendo.mobile.Application(); //writes title of the displayed view to the console.console.log(application.view().title);
Navigating to a view
In the previous examples we saw how we can navigate to other views declaratively. But what if you want to navigate to a screen using JavaScript? There is a solution for that too. The Application object that we created in our first example has a navigate()
method, which can be used to perform navigation between views using JavaScript code. The method takes two parameters: URL to navigate, and transition effect (optional).
This is how we initialized our Kendo UI Mobile application:
var app = new kendo.mobile.Application();
Now we can make use of this object app to invoke the navigate(url, transition)
method to navigate to another screen:
app.navigate("Trailers.html")
You can even use:
app.navigate("#mt-about-view", "slide")
Tip
navigate("#:back")
will take you back to the previously visited view.
- 從零開始:數(shù)字圖像處理的編程基礎(chǔ)與應(yīng)用
- 自己動(dòng)手寫搜索引擎
- Visual C++程序設(shè)計(jì)學(xué)習(xí)筆記
- C# 從入門到項(xiàng)目實(shí)踐(超值版)
- Spring Cloud、Nginx高并發(fā)核心編程
- Lua程序設(shè)計(jì)(第4版)
- Visual C++數(shù)字圖像處理技術(shù)詳解
- Python算法從菜鳥到達(dá)人
- C語言程序設(shè)計(jì)習(xí)題與實(shí)驗(yàn)指導(dǎo)
- MySQL程序員面試筆試寶典
- C指針原理揭秘:基于底層實(shí)現(xiàn)機(jī)制
- Arduino Wearable Projects
- Windows Phone 8 Game Development
- Android Game Programming by Example
- JavaScript悟道