Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arenoir opened this issue May 8, 2015 · 10 comments
Open

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

arenoir opened this issue May 8, 2015 · 10 comments

Comments

@arenoir
Copy link

arenoir commented May 8, 2015

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
Copy link
Author

arenoir commented May 9, 2015

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 added a commit to arenoir/ember-cli-selectize that referenced this issue May 10, 2015
…ntent changes.

I have decided using the data down actions up paradigm to be more
manageable.

change `selection` property to oneWay.
remove `value` property.
@miguelcobain
Copy link
Owner

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?

@arenoir
Copy link
Author

arenoir commented May 12, 2015

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

@RuslanZavacky
Copy link

@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 )

@marcemira
Copy link
Contributor

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?

@miguelcobain
Copy link
Owner

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

@miguelcobain
Copy link
Owner

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.

@arenoir
Copy link
Author

arenoir commented Sep 9, 2015

@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.

@marcemira
Copy link
Contributor

@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)

@miguelcobain
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants