ember-cli-selectize icon indicating copy to clipboard operation
ember-cli-selectize copied to clipboard

Value and/or selection set to null on tear down.

Open arenoir opened this issue 9 years ago • 10 comments

I am running into issues when the content changes during tear down of the component. It appears the _onItemRemove function is being called thus setting the value to null. I think moving to the data down actions up methodology will fix this problem.

So before I attempt this I thought I would ask how should this work?

I feel this component should two way bind a value as well a support ddau. I am thinking the value property should be a two way binding and selection a one way binding.

So one can either use the value property or the selection property with the select-item action.

Is this a good approach?

arenoir avatar May 08 '15 21:05 arenoir

So this issue is not happing on tear down it is happening when ember data saves a object with associations. For instance I have a Task that belongs to a Person. Using this component you can choose the Person.

When saving the Task ember data removes and then re adds the person. ember-cli-selectize then decides that the person is not in the list and sets the person attribute to null using the following callback _onItemRemove

arenoir avatar May 09 '15 23:05 arenoir

This is strange. I'm using this component with Ember Data and didn't have any problems.

Please tell us some more info, like the template you're using, etc.

When saving the Task ember data removes and then re adds the person.

This part makes me confused. Is it because your backend isn't returning the association? Is the person really associated after save or is it null?

miguelcobain avatar May 11 '15 10:05 miguelcobain

@miguelcobain yes when saving the Task the server responds with the associations side loaded. I am not sure what the template is.

arenoir avatar May 12 '15 02:05 arenoir

@arenoir I was experiencing the same issues, but my problem was, that I've specified value & selection to the property:

value=value
selection=value

and it caused random results )

RuslanZavacky avatar Jul 03 '15 23:07 RuslanZavacky

Hey! Having the same issue here... I have a CRUD for a model. First time the page renders, everything works awesome as expected, then I go back to index and the back to the same route and BAM, my selections (model.myProperty) became null :/

Any idea?

marcemira avatar Jul 07 '15 22:07 marcemira

Please give us some details like the template you're using. It's working fine here.

miguelcobain avatar Jul 07 '15 22:07 miguelcobain

I have this issue when the following happens:

  1. Set content and selection
  2. Set content to [] (ember-data does this by some reason)
  3. selection becomes null
  4. Set content to some non-empty array
  5. selection is still null

This is due to how selectize works. Basically the possible options become non-existing, and selectize assumes that the current options was deselected, thus the selection is set to null.

Solutions are welcome.

miguelcobain avatar Sep 07 '15 13:09 miguelcobain

@miguelcobain I have transitioned to a DDAU approach. It is not ideal but at least I can prevent the mutation in the select-item action.

I think a completely ember select component is needed. I started a addon its a start and would appreciate your input.

arenoir avatar Sep 09 '15 18:09 arenoir

@arenoir @miguelcobain indeed, Ember 2.x road will be all about DDAU, I think there's a lot of stuff to do on ember-cli-selectize in order to be fully compatible with it (and error free)

marcemira avatar Sep 09 '15 18:09 marcemira

@arenoir Maybe we should join forces: https://github.com/miguelcobain/ember-select

miguelcobain avatar Sep 09 '15 21:09 miguelcobain