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

Each iterator on the repeated DOM element instead of container #23

Closed
lmartins opened this issue Apr 28, 2014 · 4 comments
Closed

Each iterator on the repeated DOM element instead of container #23

lmartins opened this issue Apr 28, 2014 · 4 comments

Comments

@lmartins
Copy link

Following the iteration example, i've noticed that the directive is passed in the container element instead of the element being cloned at each loop.

This might present some limitations, one example being the following.
Let's say I have a ul that contains my data items. When there are no items to show I wan't to show an li with some specific formatting. If I try that now, just by having the extra liinside the element where each is applied it breaks.

This is more a question than a suggestion, just curious about the reasons behind that design option.

@anthonyshort
Copy link
Contributor

Can you post a code example? I think I know what you mean, just want to check

@lmartins
Copy link
Author

I first noticed this when trying to run the following:

customSMSTemplate = """
    <div class="SMSList">
      <div class="SMSList-add">
        <input type="text" ref="number" on-enter="{{ this.add }}" />
        <button on-click="{{ this.add }}">Add</button>
        <button on-click="{{ this.sort }}" hidden="{{ emptyList }}">Sort</button>
        <button on-click="{{ this.clear }}" hidden="{{ emptyList }}">Remove All</button>
      </div>
      <ul class="SMSList-list">
        <li each="{{items}}" >{{number}} <button on-click="{{ this.removeItem.bind(this, $index) }}">Remove</button></li>
         <li class="empty">Message when no data</li>
      </ul>
    </div>
"""

@anthonyshort
Copy link
Contributor

Mainly because it causes weird complications with having to worry about the order bindings are processed. That leads to a whole lot of weird mess that can usually be avoided by modifying the markup a little bit.

It could work if there was a limitation that you couldn't use other directives on the same element if you're using each. It's also a design of the plugin and not ripple, so we can change that without it affecting core :)

@lmartins
Copy link
Author

Sure, thanks for the clarification. As I've said, it was more curiosity than anything and indeed im more interested in explore how to control that kind of stuff with directives.

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