【发布时间】:2015-07-02 14:58:54
【问题描述】:
我对 bootstrap-toggle (http://www.bootstraptoggle.com/) 和 durandal 有疑问。 我想用更大更好的拨动开关替换普通的复选框,以便移动用户可以更好地访问它们。
所以在 durandal 中,我将 css 包含在 index.html 中(没有示例,因为与文档相同)和 main.js 中的 js:
requirejs.config({
paths: {
'text': '../lib/require/text',
'durandal':'../lib/durandal/js',
'plugins' : '../lib/durandal/js/plugins',
'transitions' : '../lib/durandal/js/transitions',
'knockout': '../lib/knockout/knockout-3.1.0',
'bootstrap': '../lib/bootstrap/js/bootstrap',
'bootstrap-toggle': '../lib/bootstrap/js/bootstrap-toggle.min',
'jquery': '../lib/jquery/jquery-1.9.1',
'toastr': '../lib/toastr/toastr.min',
'session': '../app/services/session',
'authentication': '../app/services/authentication',
'utility': '../app/services/utility',
'logger': '../app/services/logger'
},
shim: {
'bootstrap': {
deps: ['jquery'],
exports: 'jQuery'
}
}
});
在 shell.js 中,我加载了模块(因为默认情况下不加载引导程序):
define(['plugins/router', 'knockout' ,'session', 'toastr','logger', 'durandal/app','bootstrap','bootstrap-switch']
, function (router, ko, session, toastr, logger, app, btstrps, btstrpsw) {
var showSplash = ko.observable(false);
//...
//routing etc...
阅读文档后,我认为将复选框设置为“数据切换”就足够了:
<input checked data-toggle="toggle" type="checkbox" data-bind="checked: allCustomers" />
过去几个小时我一直在解决这个问题......也许有人遇到过类似的问题。我不知道 require-routine 是否正确加载了 toogle.js - 我该如何测试呢?
【问题讨论】:
标签: javascript css twitter-bootstrap toggle durandal