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

本文标签: javascriptRender partial view dynamicallyStack Overflow