I have code like
function populate...() {
var user = $.storage.get("particulars");
if (user) {
console.log($("#frmRegister")); // returns [] why?
$("#frmRegister").find("input[name=name]").val(user.name).end()
.find("input[name=email]").val(user.email).end()
.find("input[name=contact]").val(user.contact).end()
.find("input[name=faculty]").val(user.faculty).end()
.find("input[name=course]").val(user.course).end()
.find("input[name=year]").val(user.year).end();
}
console.log("out")
}
$(function() {
eventsViewModel.populateRegistrationForm();
})
I wonder why $("#frmRegister") returns null in the log, while in chrome when I use the console to do $("#frmRegister") I get the form
Does Knockout.js interfere with such things? My form looks like:
<form action=""
method="POST"
data-bind="submit: $root.submitRegistration, visible: !registered()"
id="frmRegister"
>
UPDATE
See http://octopus.phpfogapp.com/ for the code. The line in question is line 154. (unless I change it. If so you could probably search for $("#frmRegister").find("input[name=name]") or maybe $("#frmRegister
Instead of writing your Form like this…
Write it like this:
The jQuery has a whole bunch of issues like use of storage and data-bind as super globals, but your specific issue is:
Can be written as: