Search code examples
viewdojoibm-mobilefirstdojox.mobileworklight-studio

dojo parser error with core-web-layer.js:56


i have and app in worklight 6.0.0 and with dojo 1.9 and when i add a callback function and do the transition to this view i receive this error:

dojo/parser::parse() error at file:///data/data/com.WorklightApp/files/www/default/layers/core-web-layer.js:56

<div data-dojo-type="dojox.mobile.View" id="view_MainPage"
data-dojo-props="callback:inicializarMainPage()">
<ul data-dojo-type="dojox.mobile.Heading">

    <button data-dojo-type="dojox.mobile.ToolBarButton" src="images/persona.png"
        data-dojo-props="transition:'zoomIn',dir:'1',url:'pages/datosPersona.html'">Persona</button>
    <button data-dojo-type="dojox.mobile.ToolBarButton"
        style="text-align: center" data-dojo-props="arrow:'right'"
        onclick="validarDatosAuto();" type="button">Siguiente</button>
</ul>
<div>
    <p id="mensaje_error_main_page"
        style="font-weight: bold; text-align: center; vertical-align: middle; font-style: italic"></p>
    <hr />
    <ul data-dojo-type="dojox.mobile.RoundRectList">



        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"><label
            for="policy">Marca:</label>
            <div id="marca" style="float: right">

                <select id="marcaSelect"  onchange="cargarComboBox('marca');">
                    <option value="" selected>Seleccionar</option>
                    <option value="Chevrolet">Chevrolet</option>
                    <option value="Ford">Ford</option>
                </select>
            </div></li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"
            id="modeloLi" hidden="true"><label for="policy">Modelo:</label>
            <div id="modelo" style="float: right">
                <select id="modeloSelect" onchange="cargarComboBoxVersion()">
                    <option value="" selected>Seleccionar</option>

                </select>
            </div></li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"
            hidden="true" id="versionLi"><label for="policy">Version:</label>
            <div id="version" style="float: right">
                <select id="versionSelect"
                    onchange="removerOpcionDeUnSelect('versionSelect')">
                    <option value="" selected>Seleccionar</option>

                </select>
            </div></li>

        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"><label
            for="policy">0 KM:</label>
            <input id="ceroKMCheckBox" data-dojo-type="dojox.mobile.CheckBox" type="checkbox">
        </li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"><label
            for="policy">A&ntilde;o:</label>
            <div id="anio" style="float: right">
                <select id="anioSelect">
                    <option value="2013">2013</option>
                    <option value="2012">2012</option>
                    <option value="2011">2011</option>
                </select>
            </div></li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"><label
            for="policy">GNC</label> <input id="gncCheckBox"
            data-dojo-type="dojox.mobile.CheckBox" type="checkbox"></li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"><label
            for="policy">Provincia:</label>
            <div id="provincia" style="float: right">
                <select id="provinciaSelect" onclick="" autofocus="autofocus"
                    onchange="cargarComboBox('provincia');">
                    <option value="" selected>Seleccionar</option>
                    <option value="Cordoba">Cordoba</option>
                    <option value="buenosAires">Buenos Aires</option>
                    <option value="santaFe">Santa Fe</option>
                    <option value="sanLuis">San Luis</option>
                    <option value="mendoza">Mendoza</option>
                    <option value="capitalFederal">Capital Federal</option>
                </select>
            </div></li>
        <li data-dojo-type="dojox.mobile.ListItem" class="mblVariableHeight"
            id="localidadLi" hidden="true"><label for="policy">Localidad:</label>
            <div id="localidad" style="float: right">
                <select id="localidadSelect"
                    onchange="removerOpcionDeUnSelect('localidadSelect')">
                    <option value="" selected>Seleccionar</option>
                </select>
            </div></li>


    </ul>
</div>

Is there something that im missing or im doing wrong?


Solution

    • There is no "callback" property on dojox/mobile/View. As you can read in the documentation, the property does exist on dojox/mobile/_ItemBase and its subclasses such as dojox/mobile/ListItem.
    • With your code, inicializarMainPage() happens to be executed precisely because you have used () in the the value of "callback" in the data-dojo-props attribute of the View. The parser evaluates the right-hand of your "callback: inicializarMainPage()", and this executes your function. If you replace "callback" by anything else, it will still be called...
    • As suggested by David, the "()" suffix is incorrect and should be removed, and this holds for both the "callback" property (which should be moved to the list items), and for the onclick="validarDatosAuto();".
    • Fixing these issues, and ensuring all the modules used in the HTML are properly required (you need to require at least dojox/mobile and dojox/mobile/CheckBox), I do not get any parsing error in either Dojo 1.8.3 or 1.9.