admin管理员组文章数量:1428275
I've one more question. I have a view which is containing an "add" link. Everytime I press this link a partial view should be added dynamically (for example with jQuery).
I've tried to do that by this way:
$('#Div1').load('<%= Url.Action( "Video", "ddd", new { id = "1", url="ko" } ) %>');
But this method do not add a partial it just replace the content of "Div1" with the partial.
When I try:
$('#Div1').append('<%= Url.Action( "Video", "ddd", new { id = "1", url="ko" } ) %>');
there is something added to my Div but no partial view. Just the path of the partial view is added: /de/Market/ddd/Video/1?url=ko
My code in the controller looks like this:
public ActionResult Video(string url, int id)
{
ViewModels.Video v = new Video();
v.URL = url;
v.ID_Video = id;
return PartialView("Video", v);
}
Any ideas how to solve this problem? (I'm using MVC2)
I've one more question. I have a view which is containing an "add" link. Everytime I press this link a partial view should be added dynamically (for example with jQuery).
I've tried to do that by this way:
$('#Div1').load('<%= Url.Action( "Video", "ddd", new { id = "1", url="ko" } ) %>');
But this method do not add a partial it just replace the content of "Div1" with the partial.
When I try:
$('#Div1').append('<%= Url.Action( "Video", "ddd", new { id = "1", url="ko" } ) %>');
there is something added to my Div but no partial view. Just the path of the partial view is added: /de/Market/ddd/Video/1?url=ko
My code in the controller looks like this:
public ActionResult Video(string url, int id)
{
ViewModels.Video v = new Video();
v.URL = url;
v.ID_Video = id;
return PartialView("Video", v);
}
Any ideas how to solve this problem? (I'm using MVC2)
Share Improve this question edited Apr 19, 2011 at 10:06 kapa 78.8k21 gold badges165 silver badges178 bronze badges asked Apr 19, 2011 at 9:33 HW90HW90 1,9832 gold badges22 silver badges45 bronze badges2 Answers
Reset to default 5You can add your dynamically loaded content wrapped in individual divs to #Div1 as a container:
$('<div>').appendTo('#Div1').load('<%= Url.Action( "Video", "ddd", new { id = "1", url="ko" } ) %>');
Use
$('#Div1').append(...)
This should help.
本文标签: javascriptRender partial view dynamicallyStack Overflow
版权声明:本文标题:javascript - Render partial view dynamically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745507951a2661332.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论