如何制作它以便我可以在console.log()
中显示inputName
的价值。我目前一无所获 - 我错过了什么?
代码:
$(function(){
$.fn.editable.defaults.mode = 'inline';
var inputName = $(this).data("title");
$('.updateField').editable({
type: 'text',
url: '/post',
pk: 1,
placement: 'top',
title: 'Enter public name',
toggle:'manual'
});
$('.edit').click(function(e){
e.stopPropagation();
console.log("inputName");
$('.updateField').editable('toggle');
$('.edit').hide();
});
$(document).on('click', '.editable-cancel, .editable-submit', function(){
$('.edit').show();
})
//ajax emulation. Type "err" to see error message
$.mockjax({
url: '/post',
responseTime: 100,
response: function(settings) {
if(settings.data.value == 'err') {
this.status = 500;
this.responseText = 'Validation error!';
} else {
this.responseText = '';
}
}
});
});
答案 0 :(得分:1)
删除引号:console.log(inputName);