저장, 인쇄 및 세로 인쇄 기능이있는 MVC4 응용 프로그램이 있습니다. 아래의 은 이벤트가있는 세 개의 버튼에 대한 html 코드입니다. 나는 인쇄 세로/가로 버튼, SaveDetails의 컨트롤러 메소드가 트리거지고를 클릭하지 않고 직접 저장을 클릭하면 클릭에클릭 이벤트로 다른 버튼 이벤트 발생
<input type="submit" id="btnSave" value="Save" class="button-new red" onclick=" return SaveDetails();" style="width: 20px;" />
<input type="submit" id="btnExportLandscape" value="Print Landscape" onclick="return ExportForPrint(1);" class="button-new red" style="width: 110px;" />
<input type="submit" id="btnExportPortrait" value="Print Portrait" onclick="return ExportForPrint(2);" class="button-new red" style="width: 90px;" />
나는 자바 스크립트 함수를
function SaveDetails()
{
....
if()
return true
}
function ExportForPrint(type)
{
if(type=1)
document.formCreateDetails.action="CreateDetails/ExportLandscape"; //Call to controller method
else if (type=2)
document.formCreateDetails.action="CreateDetails/ExportPortrait";
}
있습니다. 그러나 인쇄 세로/가로를 클릭 한 다음 저장을 클릭하면 여전히 세로/세로 인쇄 이벤트가 트리거됩니다. 우리는이
$(document).ready(function(){
$("#btnSave").on('click',function(){
// Do some thing.....
});
$("#btnExportLandscape").on('click',function(){
// Do some thing.....
});
$("#btnExportPortrait").on('click',function(){
// Do some thing.....
});
});
'type = 1'을 (type == 1)로 변경하고 'type = 2'를 (를) 변경하십시오. –
@amit 나는 모바일에서 응답으로 ur 코멘트를 참조하십시오. –