You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to change the scroll position of the page when i click a button inside a modal. The problem is that on the hide of the modal, it tries to focus the button that showed the modal at the beginning. The line $this.is(':visible') && $this.trigger('focus') is responsable of this behavior. The prevent this, I tried to execute e.preventDefault() on the show event but the modal is not showing at all.
So how can i prevent this to happen?
// MODAL DATA-API
// ==============
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this)
var href = $this.attr('href')
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
if ($this.is('a')) e.preventDefault()
$target.one('show.bs.modal', function (showEvent) {
if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
$target.one('hidden.bs.modal', function () {
$this.is(':visible') && $this.trigger('focus')
})
})
Plugin.call($target, option, this)
})
The text was updated successfully, but these errors were encountered:
cvrebert
changed the title
how can i adjust the scroll position of the page but modal prevent me to do it
how to stop the modal from refocusing its trigger button after being hidden?
Jun 23, 2015
I need to change the scroll position of the page when i click a button inside a modal. The problem is that on the hide of the modal, it tries to focus the button that showed the modal at the beginning. The line
$this.is(':visible') && $this.trigger('focus')
is responsable of this behavior. The prevent this, I tried to executee.preventDefault()
on the show event but the modal is not showing at all.So how can i prevent this to happen?
The text was updated successfully, but these errors were encountered: