Moment.min.js这个.Format不是一个函数

Moment.min.js this.format is not a funtion

本文关键字:一个 函数 js min 这个 Format Moment      更新时间:2023-09-26

我试图在可编辑中使用组合,然而,当我试图保存moment.min.js说这。格式不是一个函数。这是来自moment。js的代码:

$('#start').editable({
  viewformat: 'DD-MM-YYYY',
  success: function(result, newValue){
    return $.ajax({
      url: '/Project/Edit',
      data: { id: '1', NewValue: newValue, type: 'StartDate' },
      success: function (result) {
        if (result.Success == 'Success') {
          notify('The Start Date was successfully updated.', 'success');
        } else {
          notify('The Start Date could not be updated at this time.', 'error');
        }
      }
    });
  }
}).on('hidden', function () { 
  $(this).parent().next().children().removeClass('disabled');
});

这是moment.js中调用的行

toString: function () { return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")

moment.js中的这一行在可编辑的成功函数被调用之后被调用。

我明白了。我必须在ajax调用中对newValue调用.format()方法。这就是js给出错误的原因。下面是工作代码:

$('#start').editable({
  viewformat: 'DD-MM-YYYY',
  success: function(result, newValue){
    return $.ajax({
      url: '/Project/Edit',
      data: { id: '1', NewValue: newValue.format('MM/DD/YYYY'), type: 'StartDate' },
      success: function (result) {
        if (result.Success == 'Success') {
          notify('The Start Date was successfully updated.', 'success');
        } else {
          notify('The Start Date could not be updated at this time.', 'error');
        }
      }
    });
  }
}).on('hidden', function () { 
  $(this).parent().next().children().removeClass('disabled');
});