Find element in sharepoint dialog

10/01/2018 13:33

The case is we have scripts included in master page and there is method location. By calling this method we want to find element in open dialog and update it. As jQuery can find it in context of local dialog and not from root window, we used following code:

 

var modalDialog = SP.UI.ModalDialog.get_childDialog();
        var modalDialogFrame;
        if (modalDialog) {
            modalDialogFrame = modalDialog.$0_0;
        }
        if (modalDialogFrame) {
            var hiddenResizeType = modalDialogFrame.contentWindow.document.getElementById('ctl00_PlaceHolderMain_sitImageResizeType');
            hiddenResizeType.value = "Small";
        }
var modalDialog = SP.UI.ModalDialog.get_childDialog();
        var modalDialogFrame;
        if (modalDialog) {
            modalDialogFrame = modalDialog.$0_0;
        }
        if (modalDialogFrame) {
            var hiddenResizeType = modalDialogFrame.contentWindow.document.getElementById('ctl00_PlaceHolderMain_sitImageResizeType');
            hiddenResizeType.value = "Small";
        }