These are chat archives for canjs/canjs

Aug 2017
old: {(one})=“two”
new: one.bind=“two” => won’t work, am I doing it right?
sorry.. I just realized while typing is one:bind=“two”
Nico R.
Aug 30 2017 17:24

I asked this in the wrong forum, but here it goes:

I have a component that I include that loads data for a <select> element. The problem I have is that I need a two way binding because I can either load the selected value from the database value or set it based on the selection. The problem is at loading time it seems that the value is null for a while so it won't read the data from de DB. This won't happen if you reload the page, only when traversing using links within the app.

So the problem looks like in the two way binding when loading the select options it will delete the value of the selected item before finishing loading the options.

Any thougths?

Kevin Phillips
Aug 30 2017 17:26
can you use an {{#if}} to decide what <option>s to show?
Nico R.
Aug 30 2017 19:54

@phillipskevin it looks like this:

{{#if myPromise.isResolved}}
  <select {($value)}="selected">
    <option value="">Select an option</option>
    {{#if defaultvalue}}
      <option value="{{defaultvalue}}" selected>{{defaulttext}} (default)</option>
      <option>Select an option</option>
    {{#each myPromise.value}}
      <option value="{{_id}}">{{name}}</option>

and the binding like this:

<my-comonent {(selected)}="selectRetailPackageUnitId" defaultvalue="595aad9aa476ac2b25dce2db" defaulttext="this is default text" />
so it will always load “Select an option"
even if defaultvalue is set or if “selected” value (selectRetailPackageUnitId) has already been retrieved from the DB
it might be related to progressive loading
Nico R.
Aug 30 2017 20:00
@phillipskevin generally speaking when reloading everything is fine, but when using route or urls somehow things work in a different way
Kevin Phillips
Aug 30 2017 20:14
if it's possible to reproduce it in a JSBin that would really help figuring out what's going on
Nico R.
Aug 30 2017 21:03
@phillipskevin I removed the progressive loading imports and it works fine
where can I find more information related to progressive loading so I can make it work?
I’ll ask this in donejs forum