Run JavaScript from an HTML button onclick event

HTML

<div class="feedback" style="text-align: right;"><button id="feedback-btn" class="btn"> <img src="exclamation-mark.png" width="25px" height="25px" /> </button></div>

JavaScript (change ‘component_ID’ to your component ID

TB.render('component_ID', function(data) {
	$('#feedback-btn').on('click',function(){
        var url = "http://www.example.com";
        var width = 960;
        var height = 1040;
        var left = screen.width - 400;
        var top = 5;
        var params = "width=" + width + ", height=" + height;
        params += ", top=" + top + ", left=" + left;
        params += ", directories=no";
        params += ", location=no";
        params += ", menubar=no";
        params += ", resizable=no";
        params += ", scrollbars=no";
        params += ", status=no";
        params += ", toolbar=no";
        newwin = window.open(url, "customWindow", params);
        if (window.focus) {
        newwin.focus();
        }
        return false;
	})
});
4 Likes

@Chem Thanks for helping on this one! I actually went with a standard window.open() popup because I couldn’t figure out how to create a popup modal with a form.

The goal was to be able to place an “add new” button anywhere one the parent details page that would open a popup and allow you to create a related record.

I got as far as placing a button on a details page that opens a modal that was created using an HTML component. I’m just not sure how to put a new record form inside the modal.

I think I figured it out and made a post about it in a new thread.