i have view container partialview. let's customer - orders relation. view should received customerviewmodel
whereas partialview collection of orders, such ienumerable<orderviewmodel>
.
i have 2 ways of doing (not mention angular), either razor or jquery. razor pretty straightforward utilizing @html.partial("_customerorderspartial", model.orders)
. let's assume cannot use razor syntax , here how ended posting question. have read many posts on matter but, of them (not mention all), suggest use $("#container").load('@url.action("actionname", new { parameterx = valuey }))
. here questions:
- why mix razor , jquery?
- is way?
- is there way call view , pass model?
the last question has fact above code requires action on server-side called, whereas @html.partial("_customerorderspartial", model.orders)
mentioned above call view (client-side) , send given model in.
any idea on how solve helpful.
thanks in advance time , thoughts.
this code should it. trick acquire url , make sure parameter list right. used little razor url don't have to. also, if fail match parameter list, call not acknowledged. have been warned. tried name every thing in way helps.
var url = '/controllername/actionname'; $('#pnlfillmee').load(url, {nameofparam: $('#elementid').val() }, function () {callmeafterloadcomplete(); });
here's real world example use @ work. reviewinfo action in controller associated page. returns partialview result.
$(document).ready(function () { var url = '/supervisor/reviewinfo'; $('#pnlreviewinfo').load(url, { fcuname: $('#fcu').children(':selected').text(), accountsfromdate: $('#accountsfrom').val()}, function () { initializetabs(true); }); });
this goes somewhere on form.
<div id="pnlreviewinfo" style="width: 85%"></div>
edit: other jquery functions $.get, $.post , $.ajax more specialized versions of $.load. , see link might answer questions passing models:
pass model controller using jquery/ajax
hope helps
Comments
Post a Comment