views:

34

answers:

1

Hi

I have two strongly Typed partial views (Developers list and Testers list) and the respective views are Developers.ascx and Testers.ascx

Now I want to load one partial view based on the radiobutton selected. The below code is not working on radio button change.

Code Snippet:

$('input:radio[name=Type]').change(function() {

var url = '/Home/Developers'; 
if ($(this).val() === '2') { 
    url = '/Home/Testers'; 
} 
$("#result").load(url); 

});

I tried $("input[name=Type]").click(function() But din't work.

I would appreciate if anyone can provide any clue why the partial view is not loading on change event. or some guidelines.

Thanks

Rita

+1  A: 

You can try to add a line with

if ($(this).val() === '2') { 

alert('hello');

just to make sure that your code actually runs at all.

You can also call a function in the onChange()-event of the html element, instead of triggering it via $('input:radio[name=Type]').change.

Do you need to compare with three equal signs? Are you certain that the value will be '2' and not 2?

As long as the document is fully loaded and, as Marwan states above, your url:s actually point to action methods that do anything, it should work.

btw: shouldn't this be tagged with jquery or something else than just mvc?

SilverSkin