Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

There is no string only value #72

Open
stonetwig opened this issue Mar 3, 2016 · 6 comments
Open

There is no string only value #72

stonetwig opened this issue Mar 3, 2016 · 6 comments
Labels

Comments

@stonetwig
Copy link

Hey,

nice plugin!

I've noticed while using it that the value is represented as a date object which is kind of troubling when binding it to a query param (since it will basically print out the ugly version in the url bar). Is there any way to make it be string only instead of a date object?

Example in the url:
somedate=Tue%20Mar%2001%202016%2000%3A00%3A00%20GMT%2B0100%20(W.%20Europe%20Standard%20Time)

Can I solve my issue? I'm thinking of maybe creating like a wrapper component, but it's modifying a value in my controller directly which can be a bit troubling.

@soulim
Copy link
Owner

soulim commented Mar 4, 2016

Hey @stonetwig! Because you have a Date object, it's up to you how to transform it into string of any format.

Example:

var today = new Date();
today.toISOString(); // => "2016-03-04T09:20:49.447Z"

Using other methods of Date object you could extract year, day, hours, and etc.

Query param could be bound to a Date object not directly, so then you have freedom to transform it into string of required format, and also convert a string of query param into a Date object.

@soulim soulim added the question label Mar 4, 2016
@stonetwig
Copy link
Author

Hello @soulim and thanks for the response,

While I am aware how to format a date object and that I don't need to bind it directly, I kind of have to in my application since loading a specific page must fill the form out. I am unaware of when to format it since ember updates the query param automatically when I change the value in the form and it just casts the object to a string.

@soulim
Copy link
Owner

soulim commented Mar 4, 2016

Would it work for you, if you create a "proxy" property? The one that stands between query param and the Date object.

@IntellectProductions
Copy link

I need this available too.. it should be an option to have it as a string instead of date object.

@mattbearman
Copy link

I'd definitely call this a bug, the value passed to the bound property should match the value in the text field, ie: if the format param is set to yyyy-mm-dd then the bound property should be a string in that format, rather than a date object.

I appreciate for backwards compatibility this should probably be an opt-in setting, at least until v1.0

@stonetwig
Copy link
Author

@soulim Maybe with an ember computed value or something, but it feels like it creates a lot of unnecessary complexity for me. As of now I am just using normal input fields instead.

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

4 participants