Wednesday, July 11, 2012

javascript – jQuery exception with document.ready() – Object doesn't support this property or method



I\’m trying to perform some simple validation, and I\’m following some instructions in the book JavaScript & jQuery, The Missing Manual. My code is simply this:



<script src=\"~/Scripts/jquery -1.6.2.js \"></script>
<script src=\"~/Scripts/jquery .validate.js \"></script>

<form> form code here </form>

<script>
$(document).ready(function() {
$(\'#vaporizerForm\').validate();
});
</script>


And I\’m getting this error:



Unhandled exception at line 1039, column 15 in /Scripts/jquery -1.6.2.js


0x800a01b6 – Microsoft JScript runtime error: Object doesn\’t support this property or method



If I remove the $(document).ready part, and just do this, it works:



<script>
$(\'#vaporizerForm\').validate();
</script>


Any idea why the $(document).ready() part isn\’t working?


EDIT — jQuery call stack and code


enter image description here


enter image description here


enter image description here


enter image description here


EDIT – Entire code in the view



@model IEnumerable<DistributorManagement.Models.Vaporizer>

@{
ViewBag.Title = \"Vaporizer\";
}
@{
var grid = new @WebGrid(
source: Model,
rowsPerPage: 10);
}

<script src=\"~/Scripts/jquery-1.6.2.js\" type=\"text/javascript \"></script>
<script src=\"~/Scripts/jquery.validate.js\" type=\"text/javascript \"></script>

<script>
$(document).ready(function () {
$(\'#vaporizerForm\').validate();
});
</script>

<form action=\"#\" method=\"post\" name=\"vaporizerForm\" id=\"vaporizerForm\">
<div>
<label>Manufacturer</label>
<input name=\"manufacturer\" type=\"text\" class=\"required\" />

<label>BuildDate</label>
<input name=\"buildDate\" type=\"text\" class=\"required date\" />

<label>Rating</label>
<input name=\"rating\" type=\"text\" class=\"required number\" />
</div>
<div>
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</div>
</form>

<br />
<h1>Vaporizer Info</h1>
<div class=\"webgrid-wrapper\">
<div id=\"grid\">
@grid.GetHtml(
tableStyle: \"webgrid\",
headerStyle: \"webgrid-header\",
footerStyle: \"webgrid-footer\",
alternatingRowStyle: \"webgrid-alternating-rows\",
columns: grid.Columns(
grid.Column(\"Id\", \"ID\"),
grid.Column(\"Manufacturer\"),
grid.Column(\"Status\"),
grid.Column(\"BuildDate\", \"Build Date\"),
grid.Column(\"Rating\")))
</div>
</div>






Rating: 2 out of 5 based on 3 ratings


The post javascript – jQuery exception with document.ready() – Object doesn't support this property or method appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-jquery-exception-with-document-ready-object-doesnt-support-this-property-or-method.html

No comments:

Post a Comment