Wednesday 25 March 2020

getJSON and populate tingle

$.getJSON("https://jsonplaceholder.typicode.com/users/" + this.idfunction (user) {

                    var modal = new tingle.modal({
                        footer: true,
                        stickyFooter: false,
                        closeMethods: ['overlay''button''escape'],
                        closeLabel: "Close",
                        cssClass: ['custom-class-1''custom-class-2'],
                        beforeClose: function () {
                            return true// close the modal
                            return false// nothing happens
                        }
                    });

                    const htmlString = `<h1>User Information</h1>
                                        <h2>ID       : ${user.id}</h2>
                                        <h2>Name     : ${user.name}</h2>
                                        <h2>User Name:${user.username}</h2>`;
                    modal.setContent(htmlString);

                    // open modal
                    modal.open();

                    // add another button
                    modal.addFooterBtn('Ok Close!''tingle-btn tingle-btn--danger'function () {
                        // here goes some logic
                        modal.close();
                    });

                });

No comments:

Post a Comment