0

对于 sidr,它href="#targetDivToSidr"用作确定在哪个 div 上执行侧边栏的方法。这在与 AngularJS 一起使用时会出现问题,因为 # 用于路由。

<a id="confirmedEventsToggler" href="#confirmedEvents">Confirmed Events</a>
<div id="confirmedEvents">
<h1>Confirmed events</h1>
<p>Foo Lorem Ipsum Dolor Foo bar aiodnwaindawo idno adnwaiodn aiodnwaiodn wiao dnwaio dnawiodnwiaodnawiod nwi    od nwaiodnwiao</p>
</div>

<script> 
     $(document).ready(function() {
        $('#confirmedEventsToggler').sidr();
     });
</script>

上面的代码不起作用。当我单击链接但没有内容时,左侧的 sidr 出现。如何让 AngularJS 让 sidr 使用href="#..."?.

4

2 回答 2

1

无需将 sidr 切换器直接绑定到超链接,您可以使用手动切换它$.sidr('toggle', 'confirmedEvents')

<a id="confirmedEventsToggler">Confirmed Events</a>
<div id="confirmedEvents">
<h1>Confirmed events</h1>
<p>Foo Lorem Ipsum Dolor Foo bar aiodnwaindawo idno adnwaiodn aiodnwaiodn wiao dnwaio dnawiodnwiaodnawiod nwi    od nwaiodnwiao</p>
</div>

<script> 
     $(document).ready(function() {
        $('#confirmedEventsToggler').click(function() {
            $.sidr('toggle', 'confirmedEvents');
        });
     });
</script>
于 2013-11-05T17:44:12.927 回答
1

它不使用href。默认情况下,它会查找 id='sidr',但您可以使用 'name' 选项传递 id:

<a id="confirmedEventsToggler" href="#">Confirmed Events</a>
<div id="confirmedEvents">
    <h1>Confirmed events</h1>
    <p>Foo Lorem Ipsum Dolor Foo bar aiodnwaindawo idno adnwaiodn aiodnwaiodn wiao dnwaio dnawiodnwiaodnawiod nwi    od nwaiodnwiao</p>
</div>

<script> 
    $(document).ready(function() {
        $('#confirmedEventsToggler').sidr({
            name: 'confirmedEvents'
        });
    });
</script>
于 2013-11-08T20:44:38.987 回答