This repository was archived by the owner on Dec 15, 2017. It is now read-only.
Update bootstrap-datetimepicker.js solution for ember.js binding problem#147
Open
mido18 wants to merge 1 commit intotarruda:masterfrom
Open
Update bootstrap-datetimepicker.js solution for ember.js binding problem#147mido18 wants to merge 1 commit intotarruda:masterfrom
mido18 wants to merge 1 commit intotarruda:masterfrom
Conversation
problem: when change the date via mouse the textfield does not notified for change event which make it problem when using ember.js solution: adding this block of code to hide function which make ember.js binding notified to changes
|
👍 Thanks for this, applied it manually and ember.js now works with this 😄 |
Author
|
@Juvenal1228 👍 you are welcome 😃 |
|
Thanks for this @mido18. With your patch I was able to resolve the issue totally in emberjs side (ps.: I'm using ember-easyForm and Font Awesome). I created a view to represent my input with this: App.DateTimePicker = Ember.EasyForm.Input.extend
init: ->
@_super();
@classNameBindings.push('showError:' + @get('wrapperConfig.fieldErrorClass'));
Ember.defineProperty(this, 'showError', Ember.computed.and('canShowValidationError', 'formForModel.errors.' + this.property + '.firstObject'));
if !@isBlock
@set('templateName', "datetimepicker");
didInsertElement: ->
element = @
@$().datetimepicker
language: 'pt-BR'
format: 'dd/MM/yyyy hh:mm'
.on('hide', ->
element.$('input').change()
)
# show font awesome arrows
$('i.icon-chevron-up').toggleClass('icon-chevron-up fa fa-arrow-up')
$('i.icon-chevron-down').toggleClass('icon-chevron-up fa fa-arrow-down')
Ember.Handlebars.registerHelper('datetimepicker', (property, options) ->
options.hash.inputOptions = Ember.copy(options.hash);
options.hash.property = property;
options.hash.isBlock = !!(options.fn);
return Ember.Handlebars.helpers.view.call(@, App.DateTimePicker, options);
)And this is my template: = hb "label-field propertyBinding='view.property' textBinding='view.label'"
%div{ bind: { class: ":input-append :date unbound view.wrapperConfig.controlsWrapperClass" } }
= hb "input-field propertyBinding='view.property' inputOptionsBinding='view.inputOptionsValues'"
%span.add-on
%i{ :'data-date-icon' => 'fa fa-calendar', :'data-time-icon' => 'fa fa-clock-o' }
= hb "if view.showError" do
%span.text-error= hb "error-field propertyBinding='view.property'" |
|
I use this control within Ember like this: views\application_view.js.coffee EmberApp.DateTimePickerField = Em.View.extend
templateName: 'datetimepicker'
didInsertElement: ->
self = this
log "self in DateTimePickerField", self
log "valueBinding", self.valueBinding
onChangeDate = (ev) ->
self.set "value", moment.utc(ev.date).format("YYYY-MM-DD hh:mm A")
@$('.datetimepicker').datetimepicker({language: 'en', pick12HourFormat: true, pickSeconds: false}).on "changeDate", onChangeDate
# This hopefully sets the default value to what is currently in the valueBinding
@$('.datetimepicker').data("datetimepicker").setLocalDate @get("value")
# This is the kind of thing we used to do in the non Ember version
# @$('.datetimepicker').data("datetimepicker").setLocalDate Date.parse("2013-12-11 05:48:31 -0800")
# This can be used to trigger the change event
# @$('.datetimepicker').trigger('changeDate')templates\datetimepicker.handlebars templates\any_template_that_uses_a_datetimepicker.handlerbars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
problem: when change the date via mouse the textfield does not notified for change event which make it problem when using ember.js
solution: adding this block of code to hide function which make ember.js binding notified to changes
SORRY for my bad English 😄