jsonform / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Bootstrap 3 out of the box.
https://jsonform.github.io/jsonform/playground/index.html
MIT License
2.72k stars 553 forks source link

Error in Navigation Tabs when the title has more than one blank space #420

Closed Juanmenacho closed 1 year ago

Juanmenacho commented 1 year ago

If a tab is added, with a title that has more than one blank space, the display of the navigation tabs fails.

Example, tab:

{
    "title": "Movies and TV",
    "type": "tab",
    "items": [
        {
            "key": "favorite_movie",
            "type": "radiobuttons",
            "activeClass": "btn-success"
        }
    ]
}

It will generate the following HTML: <div class="tab-pane" id="navtabs-Movies_and TV">

Will cause the jQuery selector to fail when trying to retrieve the element by its ID

Example tested on https://jsonform.github.io/jsonform/playground/index.html?example=navigation-tabs Error1

One possible solution is to replace the replace function with replaceAll when constructing the element id in the template, screenshots are attached. Possible_solution

sdetweil commented 1 year ago

I wonder if there are any other characters in labels that cause similar problem

sdetweil commented 1 year ago

Screenshot_20220923-072609_Chrome

no spaces allowed in IDs. but can be escaped