DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
222 stars 79 forks source link

How to add custom class to input group #351

Closed vanithav closed 9 years ago

vanithav commented 9 years ago

Hi,

I need to add my own class to the div when i append sth. How do i achieve this? For example, I need class="input-group date".

<div class="input-group">
</div>
DmitryEfimenko commented 9 years ago

try:

@f.FormGroup().Class("date").TextBoxFor(x => x.MyInput)
vanithav commented 9 years ago

I have already tried this. This adds the class to

and not the required one.

DmitryEfimenko commented 9 years ago

Oh, you are trying to add class to the other container... There is no currently way to set it. This is one of these situations where you need more flexibility that BMVC gives you. You might need to do straight html in this case. Usually though it's not necessary. What are you trying to achieve by having this class on that div?

vanithav commented 9 years ago

yeah am using BVMC currently. I want to set the date-picker for all the date controls in the page at one go. for which i want to use

$('.input-group .date').datepicker();
DmitryEfimenko commented 9 years ago

You could do this instead:

$('.form-group .date').datepicker();

or just:

$('.date').datepicker();
vanithav commented 9 years ago

tried already. nope not working. I am using bootstrap datepicker. it renders properly only when we set it for the input-group div. if i set it for the form-group div, it is not rendering properly. it is rendering by default as inline text within the div and not on click of calendar icon.

DmitryEfimenko commented 9 years ago

That's unfortunate. There are plenty of Bootstrap datepickers too. Some work better than others. But if you really want to stick to this one, you might need to just write out html. Sorry I could not provide more help.

vanithav commented 9 years ago

No problem. I have used BMVC and got what i wanted. just wanted to know whether i can achieve it using twitter BVMC. Thanks for your time and help.