简体   繁体   中英

Implement Sidr in Durandal

I am trying to get the Sidr plugin to work in Durandal. Here's what I have

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>

To summarise my problem simply...it doesn't work! When I click on the menu button nothing happens. What do I need to do differently?

I think that you need to name the nav element if it is the menu:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM