can you call a function in a partial_view?
so I am makign this pharmaceutical mvc app and I for some reason when I do a view Page source it says It cant find my script.
so am i allowed to run a script in a partial view I would assume so since its only a naming convention
7 Replies
What's the exact error?
And does the JS code exist in the generated site code?
ah dman when I did page inspect It was just that it could not find the function PurchaseProduct(productName)
I ended up removing that bit of code
Could be because the function is declared after it's being used
One of the reason you should use
.addEventListener()
instead of onclick
yh I tried adding it before the html but still an erorr
.addEventListener(PurchaseProduct());
like that
but generally speaking can you call scripts in a partial view I thought maybe the injection in the Index.cshtml was messing things up since thats done by a javascript function too
No, not like that
And yes, you can use JS in partial views
To get some data:
thx