Auto Launch bootstrap 2.3.2 modal window? - javascript

Hello I was wondering if there was some javascript to auto launch the modal window within bootstrap 2.3.2. I am using the modal window for a form and the code for the from is on page and I want the modal window to open back up on the event of an error in the form. My code works fine and it shows the error message in the modal window bu you have to relaunch the window to see it so users may not necessarily know they have errors, so that's my dilemma.
Is there a way to do this? The page isn't refreshing so I can't say load it when the page loads, as I have seen that before.

To launch your modal you can use the following call in javascript/jQuery
$('#myModal').modal();
http://getbootstrap.com/2.3.2/javascript.html#modals

Related

Elementor Pop-up with jQuery

I have a problem. I made a custom Pop-up using elementor and now added a custom jQuery code for the pop-up menu to close on the menu-item click. I have ordered the Elementor to open via action in elementor and close via the code. Picture of elementor action for popup
The code is following.
<script>
jQuery(function($){
$(document).on('click','.elementor-location-popup .menu-item', function(event){
elementorProFrontend.modules.popup.closePopup({}, event );
});
});
</script>
The problem is, that every click on different elements on the page, for example the admin bar, the contact form etc, the popup opens, event though not ordered to do so.
Has anyone had the same issue with elementor popup?
Has it something to do with the jQuery document value? Or should I seek help from elementor?
Got the fix. It is an Elementor bug.. They still have not fixed it, even with the latest update. The issue was not with jQuery code, but with Elementor settings.
I had to eliminate all the popup conditions and triggers from elementor side and just use a dynamic elementor button opening and jQuery button closing.
Somehow the triggers produced the bug, that opened the popup on a random page click.

bootstrap datepicker in bootstrap modal

I have a modal window in the #editorWin div, which can be opened from multiple locations on the page. Each time it has a different content, coming from an Ajax query in the following way:
$('#editorWin').on('show.bs.modal', function (event) {
$('#modalCont').html('Loading...')
$.ajax({
// load AJAX content and overwrite Load... message
})
});
When the modal window is opened, I want to use a Bootstrap Datepicker widget in it. When I click on the datepicker however, the AJAX loaded content of my modal window disappears.
I suspect that opening the datepicker might trigger the show.bs.modal event and that messes with my former function but I'm not sure.
There is no JS error in the console.
I found the answer in a similar question: Bootstrap datepicker not woking in modal
To solve the issue, the show.bs.modal had to be replaced by shown.bs.modal.

Display of modal popup form when users tries to close the tab instead of logout option

I'm displaying a modal popup with small feedback form whenever the user logs off from the application. But the problem is whenever the user directly closes the tab instead of logout then I want user to fill this form and then close the tab of the browser using jquery. I used window. Unload but getting alert blocked error in console.. Any alternative way to achieve display of modal window on close of tab??

Create modal popup in NetSuite

I have a requirement to show modal popup on in netsuite on button click.
currently I open a window using client script
var url = nlapiResolveURL('SUITELET','customscript_id','customdeploy_id',null);
window.open(url);
Now I want to make this window as modal popup to prevent accessing the parent window. Please help.
You'll need to use existing solutions like
Bootsrap or Jquery UI's Modal Window.
If you want to be more elegant and avoid dependencies, you can create your own light implementation. Please, refer to how to make window.open pop up Modal?

Loading Bootstrap modal with jQuery inside - breaks original modal

I have a Bootstrap modal that is using requireJS to load jQuery inside and run JS, that show output in modal.
This setup works great for first opening of the modal. If I close the modal and try to open it again:
$("#modalLogin").modal();
I get:
TypeError: undefined is not a function
It seems that loading of jQuery inside of modal is breaking jQuery modal functionality of main page. Is there a way to re-enable .modal() method in original page, once I close the modal?
According to the boostrap modal's documentation,
You can call .modal() to initiate it, with or without options,
But you have to precise the method when you want to open / hide it :
$('#modalLogin').modal('show');

Categories