Reputation: 4321
Imagine some javascript codes will be add razor pages.
<script type="text/javascript">
$(function () {
$('#photogallery a.lightbox').lightBox();
$('#photogallery').infiniteCarousel({ imagePath: '/Content/Images/Components/InfiniteCarousel/', autoStart: false });
$(".flows").collapsiblePanel();
$("[email protected]").tabs();
});
</script>
This code need some html element defined css class by .tab and .flows. There is no sense for flows but [email protected] build in run time -because it need model-.
I would like define an attribute for controller method and I would like to add automaticaly with code.
How
[JavaScript("menu.js")]
public ActionResult Menu(object param)
{
return PartialView(this.categoryService.GetAllCategories()[0]);
}
and razor view will have automaticaly produced code with
...
$("[email protected]").tabs();
...
Is it phantasy or could be implemented in real life.
Thanks
Upvotes: 1
Views: 1062
Reputation: 887225
Your Javascript block will work fine as-is.
Just put it in the view.
Upvotes: 1