0

I will like to call two Javascript.js fonction from my view. I cannot find the proper way to do it.

My view has a text box to be able to change the quantity number of the item. I have a link to click if we want to refresh the quantity. It will recalculate the price multiply to the quantity of the item.

I have another link to click if we want to remove the item from the cart.

I isolate the two scripts under Scripts/Js - RefreshQuantity.js - RemoveFromCart.js

In my View, how should be the call the these two javascripts ?

I tried this but only the RefreshQuantity script is working.

Note: The javascripts are working fine if I leave them in the view. But I know the proper way of doing scripts is to isolate them under a folder Scripts/Js.

Index.cshtml

 <script src="/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>

 <script src="~/Scripts/Js/RemoveFromCart.js"></script>

 <script src="/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
 <script src="~/Scripts/Js/RefreshQuantity.js"></script>

Thanks for any input to resolve this.

1 Answer 1

1

Use the bundles feature of MVC and then add the necessary declaration to the bottom of your layout view. Don't pull separate scripts directly into your views - this will be a maintenance nightmare.

ASP.Net MVC 4 Bundles

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.