I'm using IBM Worklight 6.1 and backbone.js for my mobile app project. My question is, how to integrate Worklight adapter with backbone view?
Worklight adapter
Username.xml
<wl:adapter name="Username"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>Username</displayName>
<description>Username</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>example.com</domain>
<port>9081</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getUsername"> </procedure>
</wl:adapter>
Username-impl.js
function getUsername(userAlias,locale) {
path = "rest-rib/service/Login/login_username?userAlias=" + userAlias + "&locale=" + locale;
var input = {
method : 'post',
returnedContentType : 'json',
path : path
};
return WL.Server.invokeHttp(input);
}
BackboneView
HomeView.js
define(['jquery', 'underscore', 'backbone', 'text!modules/home/homeViewTemplate.html'], function($, _, Backbone, homeViewTemplate) {
var HomeView = Backbone.View.extend({
initialize: function() {
this.$el.off();
},
render: function() {
this.$el.html(homeViewTemplate);
},
});
return HomeView;
});
Not sure about an adapter, but you can take a look at this blog post and video, describing how to build MVC applications with IBM Worklight and backbone.js.
The goal of this tutorial is to demonstrate how to create a MVC application with IBM Worklight and backbone.js.
Note that solid knowledge of both Worklight and Backbone.js is recommended for a maximum result.
We will create a simple application that will retrieve RSS feed from Worklight adapter and display it on a screen. Clicking on a feed item will popup feed description in alert box.