-
Notifications
You must be signed in to change notification settings - Fork 255
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
How to share collection #85
Comments
@vtsurka You would call publish with some extra data:
If you check out the console when you run Aura you will see a bunch of messages like "Todos-bootstrap message from from: controls". Each of those messages are being published from one widget and subscribed by another widget. You just have to add the additional data to the call. |
@addyosmani I'd like to add another button to the controls that publishes extra data. If you agree, I'll commit. |
Fully agree. Feel free to :) |
Done. |
I expected send the id of model, but we have model 'Task' they use in widgets: TaskList, TaskDetailed. I don't want duplicate model ;( |
I need generate page like this When i click on link expand, will show detailed todo under row. So i have todos(as like demo app) i add method show /widgets/views/todos.js events: {
//... other events
'click .view': 'show',
},
//Show detailed info about task
show: function() {
sandbox.widgets.start('detailed',this.$el);
sandbox.widgets.publish('todo-detailed',this.model);
}, And i create widget detailed Widget main.js define(['sandbox', './views/app'], function (sandbox, AppView) {
return function (element) {
var view = new AppView({
el: sandbox.dom.find(element)
});
return view;
sandbox.subscribe('todo-detailed', 'detailed', function (todo) {
//apply model
view.model = todo;
});
};
}); View define(['sandbox', 'text!../templates/detailed.html'], function (sandbox, template) {
var AppView = sandbox.mvc.View({
template: sandbox.template.parse(template),
events: {
'click .save': 'save',
'click .start': 'start',
'click .stop': 'stop'
},
// At initialization we bind to the relevant events on the `Todos`
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize: function () {
sandbox.widgets.start('todo-history','#todo-history');
sandbox.widgets.start('todo-comment','#todo-comment');
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
}
});
return AppView;
}); Is it right way to organize widget like this? |
If i have one collection that uses many widgets, how correctly share this collection.
Sample:
Task menu (Wdiget?):
Review
In Progress
Done
Task list(Widget)
#1 Task name
#2 Task name
#3 Task name
Detailed view(Widget)
When in task list i click on "#2 Task name", i must render detailed view widget.
How correctly organize this code.
Thx.
The text was updated successfully, but these errors were encountered: