This is a migrated thread and some comments may be shown as answers.

[Solved] Partial View Help

1 Answer 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 15 Jun 2012, 09:30 PM
I have the following partial view:

@model TelerikECommerce.ViewModels.ZoneMaintenanceViewModel
 
Hello!
 
@if( Model.ElementValueList != null )
{
    foreach( var element in Model.ElementValueList )
    {
        @Html.Raw( "Hello Again" )
    }
}

Here is the main page:

@Html.Partial( "ZoneElementsPartial", Model )
 
@section JavaScript{
    <script language="javascript" type="text/javascript">
        function zone_changed() {
            var dropDownList = $('#Zone').data('tDropDownList');
 
            var urlPath = '@Url.Content( @"~\ContentAdministration\GetZone?zoneId=")';
            urlPath += dropDownList.value();
 
            $.ajax({
                url: urlPath,
                dataType: 'html',
                success: function(data) {
                    $('#ZoneElementsPartial').html(data);
                }
            });
 
        }
 
    </script>
}


The top "Hello!" outside of the code is always displayed as I would expect. However once the dropdown changes and serves up the view again what is inside the code is never output. I have put breakpoints in the code and have watched it go through the loop for each element but it is not being output to the page. What am I doing wrong??

Thanks!!



1 Answer, 1 is accepted

Sort by
0
jfkrueger
Top achievements
Rank 1
answered on 18 Jun 2012, 09:56 PM
I figured it out. Just needed wrap my partial in a div on the main page with the ID and then make sure the javascript was updating the html of that div with the result of the call.
Tags
General Discussions
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
jfkrueger
Top achievements
Rank 1
Share this question
or