Javascript error - Uncaught Typeerror - Unable to resolve

Asked

Viewed 760 times

0

Give me the following error: Uncaught Typeerror: Undefined is not a Function. I still can’t fix it. I’ve already changed jquery versions and nothing. I looked for quote errors, semicolon and still could not solve. The error is in this line of my jquery function: $('#jqxTree').jqxTree({ height: '400px', hasThreeStates: true, checkboxes: true, width: '330px' });

This is a code I picked up online. In an HTML page it worked, even was part of another post of mine that I gave as closed by the answer found. However, now that I’m switching to my view (cshtml) is what started to suck. There were 9 errors and 8 were solved, but this one I could not solve. I’ve had other problems elsewhere, with this same mistake, but this time I’m not getting it. Follow a page print at the time of the error: inserir a descrição da imagem aqui

Below my jquery function and my cshtml.

$(document).ready(function () {
    // create jqxTree
    $('#jqxTree').jqxTree({ height: '400px', hasThreeStates: true, checkboxes: true, width: '330px' });
    $('#jqxTree').css('visibility', 'visible');
    $('#jqxCheckBox').jqxCheckBox({ width: '200px', height: '25px', checked: true });
    $('#jqxCheckBox').on('change', function (event) {
        var checked = event.args.checked;
        $('#jqxTree').jqxTree({ hasThreeStates: checked });
    });
    $("#jqxTree").jqxTree('selectItem', $("#home")[0]);

    $('label.tree-toggler').click(function () {
        $(this).parent().children('ul.tree').toggle(300);
    });

});

My cshtml:

@{
    ViewBag.Title = "Acao";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}

<link href="~/Content/Jqwidgets/jqx.base.css" rel="stylesheet" type="text/css" />

<h2>Tomada de Ação</h2>

<div class="row">
    <div class="col-md-12">
        <div class="col-md-1">
            <label for="cbxCodTipo">UF:</label>
        </div>
        <div class="col-md-4">
            <select class="form-control col-md-6" name="cbxCodTipo" id="cbxCodTipo" onchange=" return MontaCidades();">
                <option value="00">Selecione um estado</option>
                <option value="AC">ACRE</option>
                <option value="AL">ALAGOAS</option>
                <option value="AP">AMAPÁ</option>
                <option value="AM">AMAZONAS</option>
                <option value="BA">BAHIA</option>
                <option value="CE">CEARÁ</option>
                <option value="DF">DISTRITO FEDERAL</option>
                <option value="ES">ESPÍRITO SANTO</option>
                <option value="GO">GOIÁS</option>
                <option value="MA">MARANHÃO</option>
                <option value="MT">MATO GROSSO</option>
                <option value="MS">MATO GROSSO DO SUL</option>
                <option value="MG">MINAS GERAIS</option>
                <option value="PA">PARÁ</option>
                <option value="PB">PARAÍBA</option>
                <option value="PR">PARANÁ</option>
                <option value="PE">PERNAMBUCO</option>
                <option value="PI">PIAUÍ</option>
                <option value="RJ">RIO DE JANEIRO</option>
                <option value="RN">RIO GRANDE DO NORTE</option>
                <option value="RS">RIO GRANDE DO SUL</option>
                <option value="RO">RONDÔNIA</option>
                <option value="RR">RORAIMA</option>
                <option value="SC">SANTA CATARINA</option>
                <option value="SP">SÃO PAULO</option>
                <option value="SE">SERGIPE</option>
                <option value="TO">TOCANTINS</option>
            </select>
        </div>
        <div class="col-md-6">
            <div class="col-md-2">
                <label for="cbxCidade">Cidade:</label>
            </div>
            <select class="form-control col-md-4" name="cbxCidade" id="cbxCidade"></select>
        </div>
    </div>

    <div class="col-md-12">
        <div class="col-md-1">
            <label for="cbxRede">Rede:</label>
        </div>
        <div class="col-md-4">
            <select class="form-control col-md-6" name="cbxRede" id="cbxRede"></select>
        </div>
        <div class="col-md-6">
            <div class="col-md-2">
                <label for="cbxRede">Descrição:</label>
            </div>
            <select class="form-control col-md-4" name="cbxDescricao" id="cbxDescricao"></select>
        </div>
    </div>

    <div class="col-md-12">
        <div class="col-md-1">
            <label for="cbxProduto">Produto:</label>
        </div>
        <div class="col-md-4">
            <select class="form-control col-md-6" name="cbxProduto" id="cbxProduto"></select>
        </div>
    </div>

    <div class="col-md-12">
        <div class="col-md-1">
            <label for="cbxUnNegocio">Unidade Negócio:</label>
        </div>
        <div class="col-md-4">
            <select class="form-control col-md-6" name="cbxUnNegocio" id="cbxUnNegocio"></select>
        </div>
    </div>
</div>
<br />

<div id="content">
    <div class="listTree"></div>
    <button class="btn btn-primary" onclick=" return CadastraUsuario();">Pesquisar</button>
</div>
<br>
<div id='jqxWidget'>
<div style='float: left;'>
    <div id='jqxTree' style='visibility: hidden; float: left; margin-left: 20px;'>
        <ul>
            <li item-checked='true' item-expanded='true'>
                Solutions
                <ul>
                    <li>Education</li>
                    <li>Financial services</li>
                    <li>Government</li>
                    <li item-checked='false'>Manufacturing</li>
                    <li>
                        Solutions
                        <ul>
                            <li>Consumer photo and video</li>
                            <li>Mobile</li>
                            <li>Rich Internet applications</li>
                            <li>Technical communication</li>
                            <li>Training and eLearning</li>
                            <li>Web conferencing</li>
                        </ul>
                    </li>
                    <li>All industries and solutions</li>
                </ul>
            </li>
            <li>
                Products
                <ul>
                    <li>PC products</li>
                    <li>Mobile products</li>
                    <li>All products</li>
                </ul>
            </li>
            <li>
                Support
                <ul>
                    <li>Support home</li>
                    <li>Customer Service</li>
                    <li>Knowledge base</li>
                    <li>Books</li>
                    <li>Training and certification</li>
                    <li>Support programs</li>
                    <li>Forums</li>
                    <li>Documentation</li>
                    <li>Updates</li>
                </ul>
            </li>
            <li>
                Communities
                <ul>
                    <li>Designers</li>
                    <li>Developers</li>
                    <li>Educators and students</li>
                    <li>Partners</li>
                    <li>
                        By resource
                        <ul>
                            <li>Labs</li>
                            <li>TV</li>
                            <li>Forums</li>
                            <li>Exchange</li>
                            <li>Blogs</li>
                            <li>Experience Design</li>
                        </ul>
                    </li>
                </ul>
            </li>
            <li>
                Company
                <ul>
                    <li>About Us</li>
                    <li>Press</li>
                    <li>Investor Relations</li>
                    <li>Corporate Affairs</li>
                    <li>Careers</li>
                    <li>Showcase</li>
                    <li>Events</li>
                    <li>Contact Us</li>
                    <li>Become an affiliate</li>
                </ul>
            </li>
        </ul>
    </div>

    <div style='margin-left: 60px; float: left;'>
        <div style='margin-top: 10px;'>
            <input id='jqxCheckBox' type="hidden">
        </div>
    </div>
</div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="col-md-2">
                <label for="txtObs">Observação:</label>
            </div>
            <div class="col-md-12">
                <textarea id="txtObs" style="width: 450px;"></textarea>
            </div>
        </div>
    </div>

    <br />

    <div id="content">
        <div class="listTree"></div>
        <button class="btn btn-success" ">Gravar</button>
        @Html.ActionLink("Voltar", "Index", "Home", new { }, new { @class = "btn btn-danger" })
    </div>

    @*<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>*@
    <script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>

    <script src="~/Scripts/jquery-2.1.0.min.js"></script>
    <script src="~/Scripts/Acao/Acao.js"></script>
    <script src="~/Scripts/Util.js"></script>



    <script src="~/Scripts/Jqwidgets/jqxcore.js"></script>
    <script src="~/Scripts/Jqwidgets/jqxbuttons.js"></script>
    <script src="~/Scripts/Jqwidgets/jqxscrollbar.js"></script>
    <script src="~/Scripts/Jqwidgets/jqxpanel.js"></script>
    <script src="~/Scripts/Jqwidgets/jqxtree.js"></script>
    <script src="~/Scripts/Jqwidgets/jqxcheckbox.js"></script>

1 answer

1

I put a $ inside the Function and it worked, but I don’t know if it would be right.

It was like this my Function:

$(document).ready(function ($) { ... }); 
  • 7

    That one $ that you have passed ensures that within this function $ refers to jQuery. The moment you turn the ready, $ out of function was probably reset to something else (another library was loaded, or another version of jQuery).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.