本文介绍了带Razor View的MVC动态添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含导航页脚的母版页(MasterLayout.cshtml)



I have a master page (MasterLayout.cshtml) that has footer with navigation

<div id="back_footer_button_placeholder"></div>





在加载的另一个页面中,我只需用




In another page when it loads I just replace that placeholder with

$("#next_footer_button_placeholder").html("<a class='button' title='Edit' href='java<!-- no -->script:return false;'  önclick='nextBenefit();'><span class='icon_enrollnow'>Next</span></a>");





当我点击按钮时,它第一次不起作用但仅在第二次工作但是如果我用这个替换上面的代码





When I click the button it does not work the first time but works on the second time ONLY however if I replace the above code with this

<a class="button" title="Edit" href="java<!-- no -->script:return false;"  önclick="nextBenefit();"><span class="icon_enrollnow">Next</span></a>





它适用于第一次点击。



我的问题是为什么它这样做?还有另一种方法,更简单的方法来替换页脚中的按钮吗?



谢谢。



It works on the first click.

My question is this why it does that? And is there another way, an easier way, to replacing buttons in the footer?

Thank you.

推荐答案





当我点击按钮时它第一次不起作用,但仅在第二次工作但是如果我用这个代替上面的代码





When I click the button it does not work the first time but works on the second time ONLY however if I replace the above code with this

<a class="button" title="Edit" href="java<!-- no -->script:return false;"  önclick="nextBenefit();"><span class="icon_enrollnow">Next</span></a>





它适用于第一次点击。



我的问题是为什么它这样做?还有另一种方法,更简单的方法来替换页脚中的按钮吗?



谢谢。



It works on the first click.

My question is this why it does that? And is there another way, an easier way, to replacing buttons in the footer?

Thank you.


<html>
<head>
<script src="http://codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
<script>
function nextBenefit() {
	alert("function called");
}



这篇关于带Razor View的MVC动态添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:25