-
Notifications
You must be signed in to change notification settings - Fork 66
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
Firing events/methods when data changes #18
Comments
I'd probably just use <div each="{{ items }}"></div>
<div hidden="{{ !item.length }}">No items to show</div> That's probably the easiest way for that. |
|
Thanks for the suggestion Anthony. But what if I also needed some logic to toggle the state of the "order" and "delete all" buttons, how would you hook that? Sent from my iPhone
|
Depends on the sort of logic. If it's just whether there are any items, I'd just do Otherwise if there's more logic around it, you could use computed properties or just listen for changes to the items array. CustomSMS.created ->
@data.items.on 'change', =>
if @data.items.length then @set 'canDeleteAll', true (My coffeescript might be a little rusty) The array fires a <button hidden="{{ !canDeleteAll }}"></button> |
Cool, that gives me a path to explore. Thanks again Anthony, I'll close this issue once I'm on my computer. Cheers. Sent from my iPhone
|
Two quick questions Anthony,
Thank you. |
|
Ok, I think i'll wait for clarification in the docs, while doing some more testing. I still didn't get it to work, having some scope issues, because the @data.items is returning undefined on the scope it is running. Not sure why because doing a Another thing i've noticed, not sure if it is normal, is that the event fires 4 times (1 + 3), apparently what it is happening is that the event fires when the view is first created and then one time for each item in the data.items array. |
Within the event handler The second one is a bug, I've added it to my list of things to fix up tonight :) |
Ok, im closing this now while im investigating why I can't bind the Thanks for all the help. |
Pretty sure the issues you're having are directly related to #21. The |
I believe so, yes, the errors im getting happen on the second time the event fires, which by then is bound to the |
Yup! It's here https://github.com/ripplejs/each/blob/master/index.js#L45 Need to make that have it's own View rather than re-using the parent one. |
Cool, definitely I'm learning something here despite the frustration of being unable to make it work :-) |
Following Anthony's suggestion, im posting this question here since there isn't yet a StackOverflow or forum where this kind of request probably fit better.
Hope you don't mind and can point some directions to where look further.
Im trying to build a small component, based on the iteration example, where I have a list of numbers that I can add or remove items.
I've published the working sample here:
http://jsfiddle.net/lmartins/VPB93/
Let's say I wanted to achieve the following:
What would you suggest doing to achieve this, I though of custom events or setting an watcher on the items array using the observer plugin but im still lacking the knowledge to figure how all the parts fit together.
The text was updated successfully, but these errors were encountered: