Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Sending off Pikaday object through REST #11

Open
philippeluickx opened this issue May 21, 2015 · 2 comments
Open

Sending off Pikaday object through REST #11

philippeluickx opened this issue May 21, 2015 · 2 comments

Comments

@philippeluickx
Copy link

Hey,

I am trying to submit my data through REST and this includes a Pikaday object.
Following is the error:

TypeError: Converting circular structure to JSON
at Object.stringify (native)

I partially manage to get around by using .getString(), but then I need to check if there is an object (because the function does not work on undefined, in case the date is optional).

Probably something I am overlooking, any suggestion is appreciated!

@nverba
Copy link
Owner

nverba commented May 21, 2015

Hi,

Is there a reason to serialize the whole Pikaday object, including its methods?

@philippeluickx
Copy link
Author

I am binding a form including dates. I then submit the model linked to this form to the REST backend through rest-angular.
The challenge with pikaday-angular thus is that I would have to replace the dates from the model in the Controller, which is not a huge issue but somehow a bit less elegant.

Furthermore, I am struggling with optional date fields as well.

  1. I can disable a field, which makes that the property on that model is not present. So calling .getString() function will not work, as the date is undefined.
  2. If there is a Pikaday object, but no input, then the .getString() does work. However, in my case I can not simply submit an empty string but I need to delete the property. This however is backend specific...

So this leads to some dirty if-else statements in the code. No big deal, just pointing a potential win here for improvement.

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

No branches or pull requests

2 participants