私は自分のビューにdatepickerを使用しています。私はangularjsも使用します。問題は、私がOKボタンを使用してもそれがNGモデルの状態を変更しないということです。それでもng-emptyが表示されます。別のフィールドを計算するのにこの値を使用しますが、無視することができます。 onCloseではなくokボタンをどのようにアクティブにすることができますか?ユーザーが月と年を選択するときにngモデルが変更されていることを確認する必要があります。 私の日付ピッカー:。 Jquery datepickerボタンがうまく機能しない
$(function() {
$('.date-picker').datepicker({
yearRange: "-5:+0",
showButtonPanel: true,
dateFormat: 'MM yy',
changeMonth: true,
changeYear: true,
closeText: 'OK',
beforeShow: function() {
$(this).datepicker('widget').addClass('hide-calendar');
if ((selDate = $(this).val()).length > 0) {
iYear = selDate.substring(selDate.length - 4, selDate.length);
iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
}
},
onClose: function (dateText, inst) {
$(this).datepicker('widget').removeClass('hide-calendar');
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var mN = $("#monthNo").val();
if (mN == '') {
return;
}
var tm = parseInt(month) + parseInt(mN-1)
if (tm > 11) {
tm = tm - 12;
year =parseInt(year) + 1;
}
$("#to").val(monthNames[parseInt(tm)] + " " + year);
}
}).click(function() {
$('.ui-datepicker-calendar').hide();
}).attr("readonly", true);
});
私を助けることができます@Bharti Sharma – Fawel
datepickerは、クリックして$ scopeを実行する必要があるモデルを更新します$ apply() – alphapilgrim
どこに$ scopeを実装できますか$ apply()? – Fawel