javascript - Error while binding the selected value with DevExtreme and KnockOut -


i trying develop little app.

i have made login view , works, able bind data written user. after this, show 2 select box. first binded list (correctly) , second has bind list populated after value selected first.

i'm not able read value selected first list.

i have html:

<div class="dx-fieldset">             <div class="dx-field">                 <div class="dx-field-label">rete</div>                 <div class="dx-field-value"                      data-bind="dxlookup: { datasource: is_retistisource, value: rete, displayexpr: 'nome', title: 'retisti associati', placeholder: 'selezionare rete',                                             onselectionchanged:setrete }" />             </div>              <div class="dx-field">                 <div class="dx-field-label">impianto</div>                 <div class="dx-field-value"                       data-bind="dxlookup: { datasource: is_impiantisource, value: impianto, displayexpr: 'nome', title: 'impianti associati', placeholder: 'selezionare impianto' }" />             </div>         </div> 

and javascript:

overviewapp.afterlogin = function (params) {     var isready = $.deferred();     var viewmodel = {         rete: ko.observable(""),         impianto: ko.observable(""),         is_retistisource: overviewapp.listareti,         is_impiantisource: overviewapp.listaimpianti,         setrete: function () {             console.log(viewmodel.rete);             var nretisti = overviewapp.listaretiimpianti.length;             (i = 0; < nretisti; i++) {                 if (overviewapp.listaretiimpianti[i]["retista"]["nome"] == this.rete)                 {                     overviewapp.listaimpianti = listaretiimpianti[i]["listaimpianti"];                     break;                 }             }             is_impiantisource = overviewapp.listaimpianti;         },         close: function () {             overviewapp.app.back();         }     };     return viewmodel; }; 

in setrete function, line "console.log(viewmodel.rete);", see output:

d(){if(0<arguments.length)return d.wa(c,arguments[0])&&(d.x(),c=arguments[0],d.w()),this;a.k.ob(d);return c} 

why? how can bind , read selected value?

update: i've done in way, works:

setrete: function (e) {             overviewapp.idrete = e.value;             var nretisti = overviewapp.listaretiimpianti.length;             (i = 0; < nretisti; i++) {                 if (overviewapp.listaretiimpianti[i]["retista"]["nome"] == e.value["nome"])                 {                    overviewapp.listaimpianti = overviewapp.listaretiimpianti[i]["listaimpianti"];                     break;                 }             }             //ko.applybindings(viewmodel);         }, 

but don't know how update second list, "is_impiantisource".

observables functions. that's why function in console. call rete function value:

viewmodel.rete(); 

also see knockout: observables topic describes (under "reading , writing observables").

this how can obtain new value. then, need update dependent lookup data source. this, make is_impiantisource property observable array:

is_impiantisource: ko.observablearray(overviewapp.listaimpianti), 

after this, modify in setrene like:

viewmodel.is_impiantisource(overviewapp.listaimpianti) 

also see observable arrays how work arrays in knockout


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -