Bootstrap Modal Plugin For Durandal.js.
Tested on Bootstrap 3.2 and Durandal 2.1.0.
- Add the BootstrapModal.js into Durandal.js plugins directory.
- Activate the plugin.
app.configurePlugins({
router:true,
dialog: true,
bootstrapModal: true
});
Displays Twitter Bootstrap modal as a dialog.
Displays Twitter Bootstrap modal as a message.
define(['plugins/http', 'durandal/app', 'knockout', 'plugins/dialog'], function(http, app, ko,dialog) {
return {
displayName: 'Flickr',
images: ko.observableArray([]),
activate: function() {
if (this.images().length > 0) {
return;
}
var that = this;
return http.jsonp('http://api.flickr.com/services/feeds/photos_public.gne', {
tags: 'mount ranier',
tagmode: 'any',
format: 'json'
}, 'jsoncallback').then(function(response) {
that.images(response.items);
});
},
select: function(item) {
console.log('select')
item.viewUrl = 'views/detail';
dialog.showBootstrapModal(item, {});
},
canDeactivate: function() {
return dialog.showBootstrapMessage('Are you sure you want to leave this page?', 'Navigate', ['Yes', 'No'], null);
}
};
});