These are chat archives for canjs/canjs

18th
Aug 2018
Gregg Roemhildt
@roemhildtg
Aug 18 2018 15:35
grandfather, now I feel old ;)
qantourisc
@qantourisc
Aug 18 2018 16:53
What is the best way to call a function on the viewModel of components inantiated from can.Component.view template ?
ATM I am thinking select-by-html
Julian
@pYr0x
Aug 18 2018 17:37
why is my select broken if i use value
i want to use listenTo on a more complex szenario
something like this
  select: {
    type: "string",
    value: function (prop) {
      prop.listenTo("data", () => {
        resolve(this.data.get(0).value);
      });
    }
  },
  data: {
    get: function (lastSet, resolve) {
      this.dataPromise.then(resolve);
    }
  },
  dataPromise: {
    get: function () {
      return Select.getList(Object.assign({}, this.apiEndpoints)).then((response) => {
        // this.select = response[0].value;
        // this.select = "all";
        return response;
      });
    }
  }
but if you see in the codepen, the select is broken if i use value
if you comment out value the select will work again
qantourisc
@qantourisc
Aug 18 2018 17:59
You didn't define what was broken.
A select sorry
@pYr0x you are trying to set value by the select element. However, value does not allow setting. You might wish to be using set get instead ?
Julian
@pYr0x
Aug 18 2018 18:01
@qantourisc resovle will set the value, i thought
qantourisc @qantourisc reads up
qantourisc
@qantourisc
Aug 18 2018 18:03
hmmm works here, if I change the line prop.resolve("all"); to prop.resolve(prop);
i'm litle confused here
Julian
@pYr0x
Aug 18 2018 18:04
?
qantourisc
@qantourisc
Aug 18 2018 18:07
@pYr0x ok got it now. What do you expect to happen when you change the select v?
Julian
@pYr0x
Aug 18 2018 18:08
the select will change
and the output in the view will be the new select value
with value you cant change the select
qantourisc
@qantourisc
Aug 18 2018 18:12
so when you change the select in html
then the value:bind="value" will try to to viewModel.value = new value
or some equivalent
is value(prop) settable ?
qantourisc
@qantourisc
Aug 18 2018 18:20
as I understand is define:value is read-only
and it's value changed due to event
not because something is trying to cram data into it
qantourisc
@qantourisc
Aug 18 2018 18:44
@pYr0x