Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding values to ul #134

Closed
johannes-z opened this issue Jun 9, 2015 · 3 comments
Closed

Adding values to ul #134

johannes-z opened this issue Jun 9, 2015 · 3 comments

Comments

@johannes-z
Copy link

Is it possible to add the values to a template to achieve the following:
I have an UL with some static content. The values (in my example Entry 1 and Entry 2) should go under the divider.

<ul class="dropdown-menu" role="menu">
    <li><a href="/">Index</a></li>
    <li><a href="/site">Site</a></li>
    <li role="presentation" class="divider"></li>

    <li>Entry 1</li>
    <li>Entry 2</li>
</ul>
@cfaheyCurveJumper
Copy link

Hi @johannes-z ,

Can you show us what your data looks like?

@johannes-z
Copy link
Author

The data I have looks like that:

[
    {
        "id":"1",
        "name":"Entry 1",
    },
    {
        "id":"2",
        "name":"Entry 2"
    }
]

I want this data to result in something like the given HTML block. Problem is, I can't wrap the the entries in a div - bootstrap defines it's rules on the ul > li elements, so using a div breaks the layout.

Edit: This is what I have so far:

var entries;

entries = [
    {
        "id":"1",
        "name":"Entry 1",
    },
    {
        "id":"2",
        "name":"Entry 2"
    }
];

var directives = {
   entry: {
      html: function() {
         return this.name;
      }
   }
};

$('.container').render(entries, directives);

Template

<ul class="dropdown-menu" role="menu">
    <li><a href="/">Index</a></li>
    <li><a href="/site">Site</a></li>
    <li role="presentation" class="divider"></li>
    <div class="container">
        <li class="entry">
    </div>
</ul>

results in

<ul class="dropdown-menu" role="menu">
  <li><a href="/">Index</a></li>
  <li><a href="/site">Site</a></li>
  <li role="presentation" class="divider"></li>
  <div class="container">
    <li class="entry">Entry 1</li>
    <li class="entry">Entry 2</li>
  </div>
</ul>

@cfaheyCurveJumper
Copy link

Hi @johannes-z ,

I think you can do this a little more simply. Here's a CodePen example: http://codepen.io/anon/pen/qdjRxP

I'm rendering the menu using transparency, then prepending the other content.

It's a rough draft, but should get you going. Also, I don't think you even need a directive.

HTH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants