how can can.component returning value to user?

73 Views Asked by At

Problem: I am building a component where i just need output json object. How can i expose that output so that code can just call component and retrieve that value? (eg. like a getter value)

For e.g. can.component of tree combo as defined over here (http://canjs.com/docs/can.Component.html) allows to select the values. How can i retrieve back those selected values from can component to use it further in my code ? Like some method which would return me all the values selected which i can reuse it later to pass to some function doing some other computation.

1

There are 1 best solutions below

0
On BEST ANSWER

Have a look at https://github.com/bitovi/canjs/issues/1209, there are are several ways to accomplish this. Mainly you have three ways:

  • Pass an can.map to the child component, then the sub-component would update this object
  • Use DOM events (See 3.2.1 in link above)
  • Using can-event as a callback (See 3.2.3)