Skip to content

Change of query_parameters is not recognized when done in onchange-function #179

@knallcharge

Description

@knallcharge

I see a strange behaviour when trying to set the query_parameters of a Select2-form field. I have set query_parameters to ['var' => ''] in my form and it shows in the source-code of my page alright.
I now need to fill "var" with a value from another form-element dynamically, but the change is ignored and the value not sent to my remote_route. This strangely only happens when the change of the query_parameters are done in the onchange-event of the other field.

What works:

$('#my_element').data('query-parameters', {'var': 'value'});

Now I receive "value" in "var" in my remote_route and can process it.

What does NOT work:

$('#another_element').change(function () {
    $('#my_element').data('query-parameters', {'var': 'value'});
}

"var" is just empty in my remote_route in this case.

I have checked the contents of "var" using console.log($('#my_element').data('query-parameters')); before and after setting it and the change is done in both cases (!), only when setting it in the onchange-event, it is not transmitted to the remote_route.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions