2013-10-26 68 views
0

我想讓Sidr plugin在Durandal中工作。下面是我有在Durandal中實施Sidr

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> 

總結我的問題,只是......這是行不通的!當我點擊菜單按鈕時沒有任何反應。我需要做什麼改變?

回答

0

我認爲你需要命名nav元素,如果它是菜單:

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

嗯...有趣,我一定會嘗試這個......我用別的東西爲這個項目雖然但是謝謝 –