Sorry, I really new to js world, so forgive my dumb questions :)
and here is component
Yes, i can listen to changes in can.model.list, or params beeing passed to view containing component tags but how?
here is the code of my control
- define(['can', 'jquery', 'moment', 'models/flightsModel', 'components/resultsListComponent'], function(can, $, moment, FlightsModel){
-
- var FlightsController = can.Control.extend({
- //skipped defaults and nonrelated stuff
-
- priceSortedList: new can.List(),
- timeSortedList: new can.List(),
- originList: new FlightsModel.List(),
- searchHistory: new can.List(),
-
- init: function(el, opts){
- var _this = this;
-
- can.view('views/results.mustache', {}, function (frag) {
- _this.options.elementSearchResults.html(frag);
- $(_this.options.elementPrice).append(can.view('views/results-list.mustache', {recs: _this.priceSortedList}));
- $(_this.options.elementTime).append(can.view('views/results-list.mustache', {recs: _this.timeSortedList}));
- });
- },
-
- search: function(query, filterChain){
- var _this = this;
-
- FlightsModel.findAll(query,
- //success
- function(flights){
- _this.originList.replace(flights);
- _this.setFilterChain(filterChain);
-
- _this.priceSortedList.replace(_this.originList.sortedByPrice());
- _this.timeSortedList.replace(_this.originList.sortedByTime());
- }
- ....
- //skipped
- define(['can', 'lodash', 'jquery', 'moment', 'models/flightsModel', 'jquery.hoverIntent'], function(can, _, $, moment, FlightsModel) {
- can.Component.extend({
- tag: "results-list",
- scope: {
-
list: FlightsModel.List(),
- ...
- events: {
- "{list} change": function () {
- console.log('change fired');
- },