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

Multiple modal forms - select2 problem #28

Open
stovesy opened this issue Nov 8, 2019 · 1 comment
Open

Multiple modal forms - select2 problem #28

stovesy opened this issue Nov 8, 2019 · 1 comment

Comments

@stovesy
Copy link

stovesy commented Nov 8, 2019

I have registered two modal forms and was getting problems with missing select2 dropdowns. When the last for is rendered by ajax, only the first occurence of the select2 control was baing setup by javascript. Clearing the innerhtml when the modal closes solves this problem.

Alter kb-modal-ajax.js

    ModalAjax.prototype.init = function (options) {
        this.selector = options.selector || null;
        this.initalRequestUrl = options.url;
        this.ajaxSubmit = options.ajaxSubmit;
		jQuery(this.element).on('show.bs.modal', this.shown.bind(this));
		jQuery(this.element).on('hidden.bs.modal', this.closed.bind(this));
	};

	/**
	 * Clear inner html when the form closes. This fixes a problem where items with the same id are not
	 * rendered or have the correct javascript attached.
	 */
	ModalAjax.prototype.closed = function (event){
		jQuery(this.element).find('.modal-body').html('<div class="modal-ajax-loader"></div>');
	}
@loveorigami
Copy link
Owner

loveorigami commented Nov 18, 2019

In my case it is not worked.
I have 2 nested modal ajax.

2019-11-18_17-03-44

After closed country modal - region modal is not loaded.

Result
2019-11-18_17-08-03

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

2 participants