Display modal directly on page load without using button with materialize css - materialize

I want to load materialize modal without using button on page load. How to do that? Please help.

This will open a modal on page load. Just put it inside the document.ready function.
$('#modal1').openModal();
Be sure to replace '#modal1' with the id of the modal that you want to open.

Related

How to add div next to <ul> in bootstrap-vue dropdown-toggle?

I am using bootstrap-vue library, and I am using component to generate dropdown. However i need to add additional button. This button need to be located right after in DOM, but i have not found a way how to make it possible. If i write this button just inside component, it is not generated at all, and if i write button outside of , it is not generated after . Is there any way to generate my button right after by using v-slot or something else?

Modal is hiding automatically after showing another modal in vuejs.

I am using import bModal from 'bootstrap-vue/es/components/modal/modal'; bootstrap-modal
I have following User Interface in Modal, here I need to choose department from a dropdown(getting item list using AJAX). Here I want to make it easy to add new department by clicking button beside the dropdonw - for such popup modal with UI.
In vuejs i have code for main modal -
showModal () {
this.clearForm();
this.formInfo.formSubmitted = false;
this.$refs[this.modalInfo.id].show();
}
this is working fine. Now on click event on green button, another modal should be opened over currently opened window. Unfortunately, currently modal is get hidden and new model opened. I have following code for extra modal-
showExtraModal:function(){
this.$refs['extraModal'].show();
}
How can I solve this problem in vue js.
Seems to be a limitation of Bootstrap (see docs):
Bootstrap only supports one modal window at a time. Nested modals aren’t supported as we believe them to be poor user experiences.
Since bootstrap-vue is just a wrapper around Bootstrap, the same limitation will likely apply.
I had a similar problem with pure Bootstrap; IIRC I solved it by altering the content of the modal instead of showing a new one (in Vue-speak: rendering a different component), kind of a mini-routing inside the modal.

How to handle (X) button inside iframe using selenium

Hellow guys, please guide me to solve issue.
I am able to access all fields inside the iframe which is in div, I want to close iframe but I am unable to access (X) button.
The close button is outside iframe and inside div.
Here is my code:
To switch into iframe from main window:
BaseClassOne.driver.switchTo().frame(BaseClassOne.driver.findElement(By.xpath("//*[#id='Dealership quote Internal']/iframe")));
To access iframe element:
BaseClassOne.driver.findElement(By.xpath("//*#id='txtDealershipRef']")).sendKeys("XYZ090123");
I tried below mention code to close modal popup window:
BaseClassOne.driver.findElement(By.tagName("a")).click();// throwing no such element exception
BaseClassOne.driver.close();// this is closing browser instance
BaseClassOne.driver.switchTo().defaultContent();
// modal pop-up is not closing hence not able to access main window element
Please guide me.
Thanks in advance.
According to the above comments and discussions, I feel that you have to switch back to the default frame and then try to click on the close button.
driver.switchTo().defaultContent();
There seems to be an issue with the code sequence. Considering the close link is not contained in the iframe you have to switch to default content first and then click on close before proceeding. Try the following code:
//Switch to frame and perform actions
BaseClassOne.driver.switchTo().frame(BaseClassOne.driver.findElement(By.xpath("//*[#id='Dealership quote Internal']/iframe")));
BaseClassOne.driver.findElement(By.xpath("//*#id='txtDealershipRef']")).sendKeys("XYZ090123");
//switch to default content (to access elements outside the frame)
BaseClassOne.driver.switchTo().defaultContent();
//click on close
BaseClassOne.driver.findElement(By.xpath("//a[#class='close-window']")).click();
Note: the identifier for the close button has been changed in the code here to use the properties from the HTML sinceBy.tagName("a") which is a part of the code in the question could possible have many matching nodes which are higher up in the HTML hierarchy.

Modals inside sub-routes

I'm using angular 2 in my web application.
My application uses a lot of bootstrap modals.
I noticed that the modals contained inside a sub-route component are not showed correctly.
Infact, the modals contained inside the navbar element (the navbar is in the main state and always visible) are shown correctly, but those that are contained in the sub-route (so the html is loaded dinamically) present a bug... the shadow seems to be above the dialog itself, so it is impossible to press the buttons.
This is a screenshot:
As you can see the backdrop is above the dialog. This happen only on mobile devices.
What am I doing wrong?
I would avoid to keep all the modals inside the navbar and then open them with global events...
Thanks a lot
EDIT: I found this document:
If the modal container or its parent element has a fixed or relative
position, the modal will not show properly. Always make sure that the
modal container and its parent elements don’t have any special
positioning applied. The best practice is to place a modal’s HTML just
before the closing </body> tag, or even better in a top-level position
in the document just after the opening <body> tag. This is the best
way to avoid other components affecting the modal’s appearance and
functionality.
But is this the html of my modals (a lot of modals) is always in the dom. Isn't a heavy solution?
I fixed the problem using the following javascript code:
$('#myModal').appendTo("body").modal('show');
Thanks to Adam Albright for his post.

Materialize Create and Open Modal

I wan't to create a Modal with Materialize and Open it with a Button click. I used the code from the Modal page but it is somehow not working. Maybe someone can help.
I know some guys posted a similar question but none of them is answering my question.
For the modal example to work with a button to trigger the modal you'll need initialize the button using JavaScript. Be sure that you have included both jQuery, and both JavaScript and CSS from materialize—see the getting started guide.
To initialize the modal (or all modals) you'll invoke the leanModal() method on it:
$(document).ready(function(){
$('.modal-trigger').leanModal();
});
The "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered.
Example modal button:
<a class="waves-effect waves-light btn modal-trigger" href="#modal1">Click to open modal</a>
This button would open a modal with the id modal1.
See this code pen for a working example.