Mvc Html.ActionButton

前端 未结 7 1963
鱼传尺愫
鱼传尺愫 2020-12-16 01:52

Has anyone written one? I want it to behave like a link but look like a button. A form with a single button wont do it has I don\'t want any POST.

7条回答
  •  借酒劲吻你
    2020-12-16 02:16

    Two versions to make an extension for...

    
    

    Unobtrusive version:

    
    
    $(document).on('click', "[data-action]", 
        function(e) { window.location = $(this).attr('data-action'); }
    );
    

    If you have users which do not have javascript turned on, then form tag is the way to go. Although, this make the situation difficult if your link is already within a form. However, you could change the action and method to GET.

提交回复
热议问题