DmitryEfimenko / TwitterBootstrapMvc

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

VisibleDependsOn in an accordion #308

Closed erikadanis19 closed 10 years ago

erikadanis19 commented 10 years ago

The VisibleDependsOn dependancy only seems to work with items that are visible on load. In a scenario where these dependent fields are inside an accordion (where visible:hidden), the VisibleDependsOn field is on show even though its parent is set to "No" for example. As soon as i click on "Yes" and "No" again, the textarea will hide.

In the midterm i have found a workaround by extracting your "data-visible-depends-on" code in TwitterBootstrapMvcJs.js into a function in my own js file and run it every time a new accordion panel has finished expanding. Is there a better fix?

Also this solution works fine for textareas however when i have VisibleDependsOn on RadioButtonListFor it will hide the actual input values but not the labels that go with them. Any fix for this also?

DmitryEfimenko commented 10 years ago

Could you please provide some of the code that fails to function properly? It would help me greatly.

erikadanis19 commented 10 years ago

@using (var f = Html.Bootstrap().Begin(FormUtil.GetDefaultForm(Model))) {

using (var a = Html.Bootstrap().Begin(new Accordion("stepsAccordion").ActivePanel(1)))
{
    using (a.BeginPanel("Introduction"))
    {
        <p>Welcome to the online application form.  We have developed this form to make applying for jobs much easier and quicker, with the option to save your progress as you go. </p>

    }

    using (a.BeginPanel("Further Information"))
    {
        @f.FormGroup().RadioButtonTrueFalseFor(x => x.Relationship)
        @f.FormGroup().TextAreaFor(x => x.RelationshipDetails).VisibleDependsOn(x => x.Relationship, "true").Placeholder()

    }

    using (a.BeginPanel("Disclosure"))
    {
        @f.FormGroup().RadioButtonTrueFalseFor(p => p.HasOutstandingConvictions)
        @f.FormGroup().TextAreaFor(p => p.HasOutstandingConvictionsDetails).VisibleDependsOn(p => p.HasOutstandingConvictions, "true")

        @f.FormGroup().RadioButtonTrueFalseFor(p => p.HasDBSCertificate)
        @f.FormGroup().RadioButtonListFor(p => p.DbsLevelOfCheck, MvcUtil.GetDBSLevelOfCheck(), p => p.Value, p => p.Text).DisplayInlineBlock().VisibleDependsOn(p => p.HasDBSCertificate, "true")
        @f.FormGroup().RadioButtonListFor(p => p.DbsWorkforce, MvcUtil.GetDBSWorkforce(), p => p.Value, p => p.Text).DisplayInlineBlock().VisibleDependsOn(p => p.HasDBSCertificate, "true")

    }

}

}

erikadanis19 commented 10 years ago

The issue is with the last 3 lines VisibleDependsOn when using a RadioButtonListFor

erikadanis19 commented 10 years ago

testform

DmitryEfimenko commented 10 years ago

This is fixed. Please get latest. Make sure your BMVC's javascript file gets updated.