这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@peterjmag
Copy link

Here's my first shot at your "alternate value sent to server" todo item. With this change, if a date picker element has a parent form, we bind an event to that form to reformat the date field's value to the format defined in SETTINGS.format_submit before submitting the form. You can also disable the behavior by setting format_submit to false.

I'm still tweaking it a bit, because there are a couple of minor issues with this approach:

  • You can see the field value change for a moment before the new page loads. Also, when you navigate back to that page, the value remains reformatted (though that may or may not be a problem).
  • I haven't tested it much with AJAXy forms. I want to make sure it doesn't cause problems with other submit event handlers.
  • It might throw an error on non-<input> elements when it tries to find a parent form. I still need to play around with it, but it looks like I can solve this by using P.$element.closest('form') instead of P._element.form: http://stackoverflow.com/a/991371/349353

EDIT: Looks like you're already ignoring elements other than input, so that last point is moot. That's good, because P._element.form is quite a bit faster: http://jsperf.com/finding-an-input-s-form

If an element has a parent form, bind an event to that form to
reformat the date field's value to the format defined in
SETTINGS.format_submit before submitting the form.

The default format_submit follows the current "wire format" spec:
http://dev.w3.org/html5/spec/forms.html#input-author-notes
@amsul
Copy link
Owner

amsul commented Nov 21, 2012

Nice. I was working on this when I noticed this pull. I took some cues from this.. Thank you! :)

@amsul amsul closed this Nov 21, 2012
@amsul
Copy link
Owner

amsul commented Nov 21, 2012

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

Successfully merging this pull request may close these issues.

2 participants