Editor window not showing up on second attempt

Editor window not showing up on second attempt

kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

I have a button on my screen, clicking which an editor window opens up..
This works fine but, if I close the editor window (by clicking X) and again try to open editor again.. I only get blank popup and no content.

I am using custom form to create form layout and am always showing/hiding the form html ..

Steps to reproduce

GOTO : gadhiya.in
UNAME: kaustubh.agrawal2012@gmail.com
PWD : 12345678
GOTO : https://gadhiya.in/sauda
CLICK : Add Dispatch button
POP Opens
Close the popup by clicking (x)
Again click Add Dispatch button
 
the popup does not show anything..
 
Target Code: https://gadhiya.in/web/js/sauda.js

   $('#sauda tbody').on( 'click', 'button', function () {
        if ($(this).data('value') != 'dispatch') {
            return;
        }
        
        var row  = table.row($(this).parents('tr'));
        var data = row.data();
        var workFlow = JSON.parse(data.sauda_workflow.modules);
        var dispatchIndex = workFlow.indexOf('dispatch');
        var nextWF = workFlow[dispatchIndex + 1];

        if (typeof nextWF != 'undefined') {
                if (nextWF == 'warehouse_receipt') {
                        $('#customFormLotDetail').hide();
                    $('#customFormWHReceipt').show();
                    $('#customDefaultDispatch').hide();
                        showDispatchWithWFReceipt(data);
                } else if (nextWF == 'lot_detail') {
                        $('#customFormLotDetail').show();
                    $('#customFormWHReceipt').hide();
                    $('#customDefaultDispatch').hide();
                        showDispatchWithLotDetails(data);
                } else {
                        $('#customFormLotDetail').hide();
                    $('#customFormWHReceipt').hide();
                    $('#customDefaultDispatch').show();
                        showDefaultDispatch(data);
                }
        }
    });

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I haven't had a chance to look at your page yet (I'll do so later), but I don't see anything in your above code which executes any Editor functions. What is the code that triggers the Editor modal?

    Allan

  • kaustubh.agrawal2000kaustubh.agrawal2000 Posts: 88Questions: 39Answers: 2

    @allan
    The function

    showDispatchWithWFReceipt()
    showDispatchWithLotDetails()
    showDefaultDispatch()
    

    are the src codes that display the editor..
    For the 1st attempt it works.. but shows blank on subsequent tries..

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I think the problem is that your show* functions are creating a new Editor and adding all events every time a button is clicked. The events (e.g. show.bs.modal) aren't being cleaned up after each time a form is created - so you are ending up with lots of events all trying to do the same thing, and its gets "confused" from there.

    I would suggest that for each Editor instance you only create it and any supporting events once. Then reuse the correct Editor instance when the button is clicked on.

    Allan

This discussion has been closed.