javascript - Render partial view dynamically - Stack Overflow

I've one more question. I have a view which is containing an "add" link. Everytime I pre

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745507951a4630637.html

相关推荐

  • javascript - Render partial view dynamically - Stack Overflow

    I've one more question. I have a view which is containing an "add" link. Everytime I pre

    16小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信