Skip to content
This repository has been archived by the owner on Aug 24, 2017. It is now read-only.

Model data format not being respected #18

Open
ravinggenius opened this issue Oct 18, 2013 · 4 comments
Open

Model data format not being respected #18

ravinggenius opened this issue Oct 18, 2013 · 4 comments
Assignees
Labels
Milestone

Comments

@ravinggenius
Copy link

Is there a way to specify the expected model format? If I don't make changes to the tags, I get back what I put in, but when I do make changes, I always get back an array of objects. I want the model to always be an array of strings, possibly empty. I've looked at the documentation, and didn't see a way to force a model format.

You may have noticed by now, but I am having some other issues also (#16 and #17, specifically). Thanks for the help.

In my view:

<tags data-options="{addable: true}" typeahead-options="typeaheadOpts" data-model="document.tags"></tags>
@boneskull
Copy link
Owner

@ravinggenius What is the model of document.tags? Originally we had behavior that would ensure you got a string back if you passed it a string, but this was failing if you gave it a blank array, since it wouldn't know whether or not that was an array of strings or an array of objects. So that needs to be fixed.

@ravinggenius
Copy link
Author

Initially the model is an empty array or an array of strings. If I make changes (remove a tag or add a new tag), the model gets turned into an array of objects. Each object looks something like { $$hashKey: "051", name: "All Sites" }.

@boneskull
Copy link
Owner

Ok, right. @ravinggenius how would you like it to work? Maybe specifying a modalFormat attribute that is one of:

  • auto automatically attempt to determine model format. defaults to an array of strings (?)
  • string will keep your model a delimited string
  • arrayOfStrings will keep your model an array of strings
  • arrayOfObjects will keep your model an array of objects

@ravinggenius
Copy link
Author

What would you think of these choices for modelFormat:

  • auto automatically attempt to determine model format. defaults to an array of strings (?)
  • delimitedString will keep your model a delimited string
  • strings will keep your model an array of strings
  • objects will keep your model an array of objects

I like the shorter names, so long as they don't obscure meaning. Otherwise this is exactly what I was asking for! Thanks for helping me out with this!

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

No branches or pull requests

2 participants