Adding a view to modal & getting back to gallery view


I am trying to add a new view to modal. Once I finish working on the view, I should be able to get back to the gallery view on a button click. I have failed to find any proper documentation of

So far I was able to create backbone template and parse it into html. I can use js to insert html into the media modal but that doesn’t use the api.

Below is the JS I have written.

function render(data){
        var container = $('body .media-modal-content .media-frame-content')[0];
        var template = wp.template('wmgtpanel');
        var html = template(data);
        container.innerHTML = html;

        $('body').on('click', '.wmgt-edit', function(e) {
            container = $('body .media-modal-content .media-frame-content')[0];
            var $this = $(this);
            var id = $this.attr('data-id');
            var promise ='wmgt-media-details', {id: id});
            render({loading: true});
  , textStatus, errorThrown){
                render({error: errorThrown});





With this JS I was able to insert rendered html into the modal by replacing the existing html. But once I am done with my work. I need to get back to the previous gallery state. Which I am unable to do.

Also this method is not uses api, it just parse the template and replaces html. I would like to use existing api if possible.

Sisir 4 months 0 Answers 12 views 0

Leave an answer