在杜兰达尔实施Sidr

时间:2013-10-26 02:34:03

标签: javascript jquery requirejs durandal-2.0

我想让Sidr plugin在杜兰达尔工作。这就是我所拥有的

Main.js

requirejs.config({
paths: {
    'text': '../lib/require/text',
    'async': '../lib/require/async',
    'durandal': '../lib/durandal/js',
    'plugins': '../lib/durandal/js/plugins',
    'transitions': '../lib/durandal/js/transitions',
    'knockout': '../lib/knockout/knockout-2.3.0',
    'bootstrap': '../lib/bootstrap/js/bootstrap',
    'sidr': '../lib/sidr/jquery.sidr.min',
    'jquery': '../lib/jquery/jquery-1.9.1'
},
shim: {
    'bootstrap': {
        deps: ['jquery'],
        exports: 'jQuery'
    },
    'sidr': {
        deps: ['jquery']
    }

  }
});

Shell.js

define(['plugins/router', 'durandal/app', 'sidr'], function (router, app, sidr) {

return {
  router:router,
  activate:{...},
    compositionComplete: function (view, parent) {
            $('#simple-menu').sidr();

       return true;
    }
 }

Shell.html

<div data-bind="compose: { view: 'nav' }"></div>

<div id="wrap" class="container">
   <div class="navbar navbar-fixed-top">
        <div class="navbar-inner">

            <div class="menuicon pull-left">
                <a id="simple-menu" href="">
                    <img alt="#" src="images/menu.png" /></a>
            </div>
     </div>
   </div>

nav.html

<nav>
...
</nav>

简单地总结一下我的问题......它不起作用!当我点击菜单按钮时没有任何反应。我需要做些什么不同的事情?

1 个答案:

答案 0 :(得分:0)

我认为你需要将nav元素命名为菜单:

<nav id="sidr">
...
</nav>