Skip to content

Unable to retrieve rules when rule element IDs include colons #228

@ryansmith4

Description

@ryansmith4

I'm trying to use QueryBuilder in a JSF application. By default JSF prepends the container(s) elements to child elements using colons, which jQuery interprets as a selector.

<div id="MyForm:RuleTabs:builder" class="query-builder form-inline">
    <dl id="MyForm:RuleTabs:builder_group_0" class="rules-group-container">
        <dt class="rules-group-header">
            ...
            <div class="btn-group group-conditions">
                ...
                <dd class="rules-group-body">
                    <ul class="rules-list">
                        <li id="MyForm:RuleTabs:builder_rule_0" class="rule-container">
                            ...
                            <div class="rule-value-container">
                                <input class="form-control" type="text" name="MyForm:RuleTabs:builder_rule_0_value_0">
                            </div>
                        </li>
                    </ul>
                </dd>
                ...
            </div>
        </dt>
    </dl>
</div>

The inclusion of the colons in the element IDs prevents get/setRules from being able to retrieve/set rule values properly. The affected code appears to be in query-builder.js, in the getRuleValue/setRuleValue function, where the values of the input controls are retrieved/applied using something similar to: $value.find('[name='+ name +']').val(). When name contains colons (or other reserved selector characters), the find will fail.

This issue could be avoided, if the get/set rules escaped the rule element ids before referencing the rule's input control.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentified bug which needs a fix

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions