Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectmenu not working when on a dialog #58

Open
wluke opened this issue Sep 19, 2016 · 0 comments
Open

selectmenu not working when on a dialog #58

wluke opened this issue Sep 19, 2016 · 0 comments

Comments

@wluke
Copy link

wluke commented Sep 19, 2016

Hi!

I've noticed that selectmenu doesn't work correctly when it's included on a dialog. It seems that selectmenu needs special treatment. A simple "refresh" won't work, apparently it needs destroyed and re-created when the dialog is shown, or else either it shows the dropdown behind the dialog, or it throws an error.
So, I've added an additional parameter to the selectmenu, called "recreateOn". This can be set to a ko observable, which when changed will cause the selectmenu to be destroyed and recreated. In my setup I update this observable when the dialog is opened.

eg:

selectmenu: { width: 200, refreshOn: $data.CMIHeaderFormID.options, recreateOn: $data.dialogFullyOpen }

This is then added to the Selectmenu.prototype.update function as such:

if (allBindingsAccessor().selectmenu.hasOwnProperty('recreateOn')) {
                var hook = ko.utils.unwrapObservable(allBindingsAccessor().selectmenu.recreateOn);
                $(element).selectmenu('destroy');
                BindingHandler.prototype.init.apply(this, arguments);
            }

Might be a bit hacky, but seems to work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant