1

I've created a site that has multiple panels that slide in from the right side of the screen.

I want to be able to put a link on each panel that will share my webpage, and when the user comes to the site, that specific panel will be open.

For example:

www.something.com/#/panel-1

Will show my page with panel-1 opened, while:

www.something.com/#/panel-2 will show my page with panel-2 opened.

What's the easiest way to do this? Can I use Ember,Angular, or Backbone's router and views with only simple html? Should I just use something like router.js?

Any help, advice, or links would be appreciated.

4

1 に答える 1

0

もちろん、それはできます。これは、ember.js の最も強力な性質の 1 つです。ルートを宣言した後、フレームワークは、対応するすべてのコントローラーとビューを自動的に生成できます (これは、構成よりも規則と呼ばれます)。例を見る

Ember.Application.create({});
Ember.Router.map(function(){
    this.route('panel1');
    this.route('panel2');
});


<script type="text/x-handlebars">
    {{link-to 'index' 'index'}}
    {{link-to 'first panel' 'panel1'}}
    {{link-to 'second panel' 'panel2'}}

    <!--your panels will be inserted automatically in the outlet property-->
    {{outlet}}
  </script>

  <script type="text/x-handlebars" data-template-name="panel1">
  panel 1
  </script>
  <script type="text/x-handlebars" data-template-name="panel2">
  panel 2
  </script>

デモ: http://jsbin.com/dekixayuxa/1/

于 2014-11-15T11:27:25.543 に答える