This is a migrated thread and some comments may be shown as answers.

[Solved] Issue with class in InputHtmlAttributes

1 Answer 14 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jon Baron
Top achievements
Rank 1
Jon Baron asked on 17 Sep 2012, 04:07 PM
So I'm having a similar problem as described here:
http://www.telerik.com/community/forums/aspnet-mvc/datepicker/adding-a-css-class-through-inputhtmlattributes.aspx

In short, I need to ignore jquery validation based off certain criteria. So I attempted to use:
.InputHtmlAttributes(new { @class = "ignore1" })

In conjunction with:
<script type="text/javascript">
    // Ignore those fields we don't want to validate
    $(function () {
        var settngs = $.data($('#PersonalTab')[0], 'validator').settings;
        settngs.ignore = ".ignore1";
    });
</script>

This however throws a Jquery error @ var B=A.length; Saying Length is undefined when clicking on the ComboBox, you can tell something is off by the look of the ComboBox as well.

One thing to note, is it works through JQuery:
$(document).ready(function () {
        if (!$('#ddl').hasClass('ignore1')) {
            $("#ddl").addClass("ignore1");
        }
    });

I'd like to avoid the use of unnecessary javascript function downloads. Can anyone help on this?

Thanks!

EDIT/Fix - Change InputHtmlAttributes to HiddenInputHtmlAttributes

1 Answer, 1 is accepted

Sort by
0
Jon Baron
Top achievements
Rank 1
answered on 17 Sep 2012, 04:18 PM
Well,

Inspecting the elements shows that the class is adding to the display element, not the hidden one (where the data-val attributes are being added).
Tags
ComboBox
Asked by
Jon Baron
Top achievements
Rank 1
Answers by
Jon Baron
Top achievements
Rank 1
Share this question
or