【发布时间】:2019-07-11 09:55:09
【问题描述】:
我有一个编码的操作链接,点击它会打开一个模式弹出窗口。为了使我的应用程序可访问,我还需要能够通过按键(空格键)打开模式。单击上的效果很好,但按键却不行。请帮忙。
编码动作链接:
@Html.EncodedActionLink(
"Preview",
"Preview",
"Forms",
new {
stagingId = Model.FormData.StagingNotificationId
},
new {
@class = "'modal-link btn btn-success'",
id = "decSave"
})
点击鼠标的代码:
$(function() {
$('body').on('click', '.modal-link', function(e) {
e.preventDefault();
$(this).attr('data-target', '#modal-container');
$(this).attr('data-toggle', 'modal');
});
});
按下按键代码(触发警报但未打开模式):
$(function() {
$('body').on('keydown', '.modal-link', function(e) {
if (e.which == 32) {
alert('test')
e.preventDefault();
$(this).attr('data-target', '#modal-container');
$(this).attr('data-toggle', 'modal');
}
});
});
【问题讨论】:
标签: jquery html model-view-controller modal-dialog