0
votes

I have a main .cshtml view that uses jQuery $.Ajax to append returned PartialView result (e.g. return PartialView(partialView, model); ... from my controller action) to a div element on that main view page.

The main view page have inline javascript codes in it.

The partial view page also has some inline javascript codes in it.

The application runs OK. But at run time, I cannot see javascript codes from the partial view page with FireBug. I only see the javascripts of the main view page.

How can I see the javascript of the partial view page with FireBug? Please help.

Thank you.

1

1 Answers

1
votes

you shouldn't put javascript code in a partial view since it gets inserted into the middle of the page. Put the javascript code for the partial into the main page. To fire events on that partial you need to tie them to the document

$(document).on('click', '.Class', function(){
    // do something
});

where .Class is the selector for a field on your partial view. Let me know if you have any questions.