我有以下代码:
$("body").on("click", ".topic-name-edit.close", function (event) {
var topicId = $('#topicId').html();
var name = $(this).closest('header').find('input').val();
$(this).closest('header').html('<h1 class="blue">'+name+'</h1><span class="fake-link white-grey topic-name-edit open fa fa-pencil"></span>');
changeTopicNameService(topicId, name);
});
$("body").on("keypress", "input.topic-edit-name", function (event) {
if (event.which == 13) {
var topicId = $('#topicId').html();
var name = $(this).closest('header').find('input').val();
$(this).closest('header').html('<h1 class="blue">'+name+'</h1><span class="fake-link white-grey topic-name-edit open fa fa-pencil"></span>');
changeTopicNameService(topicId, name);
}
});
正如你在我的代码中看到的,我打电话给.on两次。有没有可能加入更多.on电话的方法? 如果没有解决方案,我怎样才能在.on调用中使用现有的var? 迎接
答案 0 :(得分:0)
您可以使用'Dummy clear statement:
ActiveSheet.Cells(1, 1).Clear
'Copy first column of cashflow formulas
Range("cashflowformulas").Copy
'Insert copied cells at end of cashflow to give additional project months
Range("endcashflow:offset(endcashflow,,10-1)").Insert shift:=xlToRight
定义全局变量,如下所示:
window
你也可以这样做:
$("body").on("click", ".topic-name-edit.close", function (event) {
window.topicId = $('#topicId').html();
window.name = $(this).closest('header').find('input').val();
$(this).closest('header').html('<h1 class="blue">'+window.name+'</h1><span class="fake-link white-grey topic-name-edit open fa fa-pencil"></span>');
changeTopicNameService(window.topicId, window.name);
});
$("body").on("keypress", "input.topic-edit-name", function (event) {
if (event.which == 13) {
window.topicId = $('#topicId').html();
window.name = $(this).closest('header').find('input').val();
$(this).closest('header').html('<h1 class="blue">'+window.name+'</h1><span class="fake-link white-grey topic-name-edit open fa fa-pencil"></span>');
changeTopicNameService(window.topicId, window.name);
}
});