Having issues calling @section scripts{...}
within a div
. Currently, it states Uncaught Error: Unknown component 'product-chooser
.
Question: How can I call my partial from within a div so that it puts the content near the top of the page?
Section of code giving me issues:
@section scripts{
@Html.Partial("ProductChooserScript", Model)
}
View: ProductSelector
<div id="productForm">
@using(Html.BeginForm())
{
<div class="col-md-6">
<div class="input-group" data-bind="visible: false, component: { name: 'product-chooser' , params: { value: TargetedProducts, available: AvailableProducts, selected: SelectedProducts }}"></div>
@* Failing Here *@
<div>
@section scripts{
@Html.Partial("ProductChooserScript", Model)
}
</div>
</div>
}
</div>
<script type="text/javascript">
function ProductSelectionViewModel(data){
var self = this;
// additional javascript/knockout logic here...
}
$(function (){
window.viewModel = new ProductSelectionViewModel(@Html.Json(Model));
ko.applyBindings(window.viewModel, $("#productForm")[0])
})
</script>
Additional Notes:
If I remove the div
surrounding @section scripts{...}
and put it at the bottom of the page, it renders the partial, but the partial gets rendered at the bottom of the page (not the desired results), I'd like it to get rendered near the top.
Please note that I did research... The other sources did not resolve this issue.