2

Since it is good practice to separate your javascript from your views, it was good to see this solution as to how to inject server variables into your javascript; https://stackoverflow.com/a/18993844/125673

However I am not clear from the answer how you can bundle up the script file in BundleConfig.cs with all of the data attributes and the id.

I would imagine it can be done, I would just like to know the syntax.

Specifically for this code;

<script src="@Url.Content("~/Scripts/Custom/TenderEdit.js")" id="jsTenderEdit"
    data-tac-tender-status-choices='@Html.Raw(Json.Encode(Model.TenderStatusChoices))'
    data-tac-tender-id="@Model.Tender.TenderId"
    data-tac-title="@Html.Raw(Model.Tender.Title)"
    data-tac-estimate-number="@Model.Tender.EstimateNumber"
    data-tac-status="@Model.Tender.Status">
</script>
Community
  • 1
  • 1
arame3333
  • 9,887
  • 26
  • 122
  • 205

0 Answers0