javascript - Stop Page Movement On PostBack On Razor Partial HtmlBeginForm -
looking similar solution effect updatepanel in web forms, mvc, below bit problem in particular. i'm sure there many ways this, ideally want best , proper way.
i have looked @ this question couldn't work.
update: can postback; mvc equivalent. need position of page maintained user's perspective.
i have tried below @ bottom of index page no dice.
@section scripts { <script type="text/javascript"> window.scrollto = function( x,y ) { return true; } </script> } as as: controller
viewbag.jumpto = "equipmentanchor"; return redirecttoaction("index"); index
<div id="equipmentanchor"></div> @section scripts { <script type="text/javascript"> $(document).ready(function () { var jumpto = '@viewbag.jumpto'; if (jumpto != "") { $(this).scrolltop($('#' + jumpto).position().top); } }); </script> } what best/easiest way achieve this?
i've seen reports ajax heavy on server, not overly fussed that, preferably no css tricks (if there any). jquery not overly familiar with, lead best solution, not particularly versed in don't know begin.
in below example list view delete button goes controller iterate through list , delete last entry list. add, or in case delete, page jumps top of index page after postback.
how should/can stop posting , reloading page, or @ least stop user experiencing it?
example code:
index:
<div class="list"> @{html.renderpartial("view", model.list);} </div> partial
@using (html.beginform("removeexisting", "pa_4")) { if (model != null) { foreach (var ri in model) { <div class="ui-grid-c ui-responsive"> <div class="ui-block-a"> <p>one</p> <span> @ri.one </span> </div> <div class="ui-block-b"> <p>two</p> <span> @ri.two </span> </div> </div> } } if (model.count() > 0) { <div> <input type="submit" value="remove"/> </div> } }
had problem answer here helped me.
download github , dump in scripts folder , reference in @section scripts
like @ bottom of view:
@section scripts { <script type="text/javascript" src="~/scripts/maintainscroll.jquery.min.js"> </script> }
Comments
Post a Comment