0

I have a problem in opening dialog using, it keeps returning error :

javascript cannot call methods on dialog prior to initialization attempted to call method 'option' in jquery 1.8.3 Following is the code

var authFormDialog = $("#authentication-form");
var role = ['ROLE_SUPERVISOR'];
var defer = $.Deferred();

authFormDialog
.removeData(AUTH_DATA_KEYS)
.data('roles', role)
.data('interventionType', interventionType)
.data('defer', defer)
.dialog('option', 'title', action + ' - SPV')
.dialog('open');

and following is the html code:

<div id="authentication-form" title="Authentication" class="container-login dialogFont" style="width: 100px; display: none;">
    <div class="auth-form dialogFont">
        <!-- <img class="img" src="/poseuser/core.static/images/logo_store.png" style="width: 70%; display: block; margin-left:auto; margin-right: auto;"/> -->
        <div>
            <span id="authFormMsg" class="error-message" style="text-align: center; padding-top: 20px;"></span>
        </div>
        <form id="authenticationForm" onsubmit="return false;" autocomplete="off">
            USERNAME&nbsp;<span id="errorauthFormUsername"></span>
            <input name="authFormUsername" type="text" id="authFormUsername" class="auth-textBox" autocomplete="off"/>
            PASSWORD&nbsp;<span id="errorauthFormEmpPin"></span>
            <input name="authFormEmpPin" type="password" id="authFormEmpPin" class="auth-textBox" autocomplete="off" maxlength="20"/>
            <span style="padding: 40px">
                <button id="authFormBtn">ENTER</button>
            </span>
        </form>
    </div>
</div>

any idea how to solve this?

3
  • 1
    Change .dialog('option'... to .dialog().dialog('option'...
    – fdomn-m
    Commented Sep 25, 2023 at 10:16
  • the error disappeared, thank you. But the styling somehow kind of changing a bit. Can you tell me a bit why chaning directly .dialog('option') to .dialog().dialog('option') solve the problem?
    – harith
    Commented Sep 25, 2023 at 11:23
  • The error message you get explains it - you're trying to set options on a dialog before it has been created. You can set properties at the time of initialisation by passing an object {..}, eg $(..).dialog({ ... }) - see here for more info
    – fdomn-m
    Commented Sep 25, 2023 at 13:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.