Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript error using this on a object
    primarykey
    data
    text
    <p>My page shows a window with a confirmation.</p> <p>If I choose Yes, the method Method1 runs but an error is generated saying that the object [Object DOMWindow] has no method 'Method2'.</p> <p>How can I solve this?</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Testes Javascript O.O.&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" /&gt; &lt;link type="text/css" href="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var vssMkt = {}; var MsgBoxSimNao = function (parMensagem, parFuncaoSim, parFuncaoNao) { /// &lt;sumary&gt;Abre uma caixa de dialogo com uma mensagem e um botao de Sim e outro de Nao.&lt;/sumary&gt; /// &lt;param name="parMensagem" type="String"&gt;Mensagem a ser exibida.&lt;/param&gt; /// &lt;param name="parFuncaoSim" type="Function"&gt;Funcao a ser executada quando clicar no Sim.&lt;/param&gt; /// &lt;param name="parFuncaoNao" type="Function"&gt;Funcao a ser executada quando clicar no Nao.&lt;/param&gt; $(this).simpledialog({ 'mode': 'bool', 'prompt': parMensagem, 'useDialogForceFalse': true, 'buttons': { 'Yes': { click: parFuncaoSim // Callback func if I press Yes }, 'No': { click: parFuncaoNao // Callback func if I press No } } }) } var Obj1 = function () { this.Method1 = function () { MsgBoxSimNao("Show message?", this.Msg1, this.Msg2 ); } this.Method2 = function () { alert('Method 2'); } this.Msg1 = function (parMsg) { alert('Yes'); this.Method2(); } this.Msg2 = function () { alert('No'); } } function onLoad() { vssMkt.test = new Obj1(); $("#link").click(function () { vssMkt.test.Method1(); }); } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="onLoad();"&gt; &lt;div data-role="page"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Javascript error&lt;/h1&gt; &lt;/div&gt; &lt;!-- /header --&gt; &lt;div data-role="content"&gt; &lt;a id="link" href="#" data-role="button"&gt;Start test&lt;/a&gt; &lt;/div&gt; &lt;!-- /content --&gt; &lt;/div&gt; &lt;!-- /page --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload