• Resolved Uwe Jacobs

    (@uwejacobs)


    Hi Miles,

    Is there something in your plugin that can create a button/link to open a modal? Or do I have to create this with custom HTML like so:

    <a class="btn position-relative btn-success" data-bs-toggle="modal" data-bs-target="#social-media-feedback"><i class="fas fa-thumbs-up fas"></i> Yes… I was satisfied</a>

    As always, thanks and keep up the good work!

    • This topic was modified 1 year, 10 months ago by Uwe Jacobs.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Miles

    (@areoimiles)

    Hi @uwejacobs

    Yes you should be able to add a button then add the modals ID as the href. Using your example you would add an All Bootstrap Blocks button block then click the link icon, then enter #social-media-feedback. You can see an example on the image here https://areoi.io/wp-content/uploads/2022/06/modal-button.png.

    If you have chosen to use your own implementation of the Bootstrap JavaScript instead of using the plugins built in one, you may need to add the following code to your JS.

    var modals = document.getElementsByClassName("modal");
    var modal_links = [];
    for (var i = 0; i < modals.length; i++) {
    	var modal = modals.item(i);
    	var links = document.querySelectorAll("[href=\'#" + modal.id + "\']");
    	if ( !links.length ) {
    		continue;
    	}
    	for (var modal_i = 0; modal_i < links.length; modal_i++) {
    		modal_links.push( links.item(modal_i) );
    	}
    }
    if ( modal_links.length ) {
    	modal_links.forEach( function( link ) {
    		link.addEventListener("click", function(event) {
    			event.preventDefault();
    			var id = link.href.split("#");
    			var modal = new bootstrap.Modal(document.getElementById(id[1]), {
    				keyboard: false
    			});
    			modal.show();
    		}, false );
    	});
    }

    Or you may want to include the following js file in your theme /plugins/all-bootstrap-blocks/assets/js/bootstrap-extra.js which should give you the additional functionality the plugin adds without needing to include all of the plugins default js.

    I hope this helps, but let me know if you still have issues and I can take another look.

    Thanks

    Miles

    Thread Starter Uwe Jacobs

    (@uwejacobs)

    Thanks for the explanation, Miles. I think I will add a “load bootstrap? (Y/N)” option to my theme. This way I can turn it off in my theme and include the All Bootstrap Blocks version.

    Having said that, it would be great if you could upgrade the ABB Bootstrap version in one of the upcoming releases from 5.0.2 to 5.1.3; see https://getbootstrap.com/docs/5.1/getting-started/download.

    Plugin Author Miles

    (@areoimiles)

    Hi @uwejacobs

    No problem, I’m glad I could help.

    Yes, I can definitely add in the latest version of Bootstrap. It’s a big job so may take a while to get it sorted but I will drop you an update over the next couple of months once it’s done.

    If you need any more assistance in the meantime don’t hesitate to get back in touch.

    Thanks

    Miles

    Plugin Author Miles

    (@areoimiles)

    @uwejacobs also, I noticed in your original question, your code example included an icon on the button. I have just added a new feature so that you can add icons to the ABB button block. You can choose from over 1,600 Bootstrap icons, change the size and whether to put it at the start or end of the button.

    To use this you can click on the button block, then open the Additional tab and toggle on Include Icon which will make a new tab appear called Icon.

    Miles

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Button for modal’ is closed to new replies.