javascript - MVC 4 using jquery how to check if the model property has elements in it -
i'm passing in view model works checkboxlistfor property , hide checkbox section if when repost page there no check marks ticked. can show , hide check box section no problem using:
$('div.ksearch').hide();
or
$('div.ksearch').show();
what i've been trying check view model has list hold information keyword model. there anyway check if list has element being passed in within jquery can show or hide section like:
if (('@model.selectedkeywords').length) { $('div.ksearch').show(); } else { $('div.ksearch').hide(); }
but shows section. ideas?
something this?
var len = @model.selectedkeywords.count; if (len > 0) { $('div.ksearch').show(); } else { $('div.ksearch').hide(); }
('@model.selectedkeywords').length
treated string length in javascript, , it's positive (and true) ;)
Comments
Post a Comment