mardi 10 février 2015

Ember Select not highlighting the item selected in previous page

I have two pages: newSim and showSim


In both newSim and showSim I have:



Candidato PAN: {{view "select" content=candidatosMarked.PAN optionValuePath="content.id" optionLabelPath="content.nombre" prompt="Seleciona un candidato..." selection=newParams.candidatosMarked.PAN}}<br/>


Both templates share the same controller.


The problem is: in the showSim, the select is not highlighting whatever value was selected in the newSim. In fact, it's not even highlighting the first item in the array (content). It just shows blank (but if you click the arrow, you can see the items in the array are there).


I've checked the binding (selection), all seems fine.... The correct values were sent to the ajax request I made to the server (that's how I know the binding is working).


After some googling I came across this: Setting Ember.Select Default Selected Value ... and I learned about this important detail: "... but it should be an item contained in the array you pass to its 'content'".


My question: How to make ember perform logical equality instead of address equality?


Background (how I end up with this situation): I do some object copyings in my code, so after some operations, the instance of selectionBinding is not the one in the list of "contentBinding" (no address equality here, although there is a logical equality.... I mean: if the instance in 'selection' is compared to each element in the 'content' -- by checking the value of all the properties, instead of just checking the address in memory --, there will be a match).


additional detail: we don't even need to compare all the properties. Each element in the 'content' has a property named 'idCandidato'. Suffice to compare that property to find a match. How to tell ember-select to use 'idCandidato' as the key for comparison?


Thanks in advance, Raka





Aucun commentaire:

Enregistrer un commentaire