I'm new to jQuery/javascript and am working on this script to get item values selected from a check box list into a textbox. I've been making progress these last two weeks, but suddenly the whole script fails to even load. The error I get is "Object doesn't
support this property or method".
<script type="text/javascript">
$("#btnCBLSelect").live("click", function () {
var selectedItems = "";
$("[id*=cblLines] input:checked").each(function () {
if (selectedItems == "") {
}
selectedItems += $(this).next().html() + ",";
});
if (selectedItems != "") {
var v1 = document.getElementById('<%=FormView1.FindControl("LineTextBoxInsert").ClientID%>');
v1.value = selectedItems.slice(0, -1);
$("[id*=cblLines] input:checkbox").prop('checked', false); // To uncheck all
$("[id*=Panel2]").fadeOut();
} else {
alert("No item has been selected.");
}
});
</script>
html of button which is inside panels:
<input type = "button" id = "btnCBLSelect" value = "Save this" />
This was working at one point but I continued to tweak it and now it fails. Any help would be appreciated.
Thanks Rion: I thought I had done something to mess my script, but it was the change in the jQuery version. I changed "live" to "on" and it works just like it did two days ago.
From now on I will link to a particular version instead of the latest:
dlanz
Member
25 Points
41 Posts
Object (button) doesn't support property (click)
Jan 16, 2013 06:37 PM|LINK
I'm new to jQuery/javascript and am working on this script to get item values selected from a check box list into a textbox. I've been making progress these last two weeks, but suddenly the whole script fails to even load. The error I get is "Object doesn't support this property or method".
<script type="text/javascript"> $("#btnCBLSelect").live("click", function () { var selectedItems = ""; $("[id*=cblLines] input:checked").each(function () { if (selectedItems == "") { } selectedItems += $(this).next().html() + ","; }); if (selectedItems != "") { var v1 = document.getElementById('<%=FormView1.FindControl("LineTextBoxInsert").ClientID%>'); v1.value = selectedItems.slice(0, -1); $("[id*=cblLines] input:checkbox").prop('checked', false); // To uncheck all $("[id*=Panel2]").fadeOut(); } else { alert("No item has been selected."); } }); </script>html of button which is inside panels:
This was working at one point but I continued to tweak it and now it fails. Any help would be appreciated.
velambath
Member
396 Points
111 Posts
Re: Object (button) doesn't support property (click)
Jan 16, 2013 06:47 PM|LINK
Hi,
this click should work perfectly, i checked in my machine also.
I got a reference that , if some additional JQuery plugin got added to our code, then this may arise.
so put all your plugin refernce properly.
also refer this : http://stackoverflow.com/questions/7417338/object-doesnt-support-this-property-or-method-jquery-simple-modal-popup
pls let us know, if u got thru ...
- Rigin
dlanz
Member
25 Points
41 Posts
Re: Object (button) doesn't support property (click)
Jan 16, 2013 09:28 PM|LINK
this is my link to jQuery; there are no others.
I have reduced the script's function to this and it still will not even load:
<script type="text/javascript"> $("#btnCBLSelect").live("click", function () { alert("This"); }); </script>Rion William...
All-Star
27656 Points
4574 Posts
Re: Object (button) doesn't support property (click)
Jan 16, 2013 10:44 PM|LINK
The .live() method has been deprecated since jQuery 1.7, instead use the .on() method :
<script type="text/javascript"> $("#btnCBLSelect").on("click", function () { alert("This"); }); </script>Since you are using the latest version from the CDN - this could explain the reason that it suddenly stopped working.
Demo demonstrating .live() vs .on()
dlanz
Member
25 Points
41 Posts
Re: Object (button) doesn't support property (click)
Jan 17, 2013 12:14 AM|LINK
Thanks Rion: I thought I had done something to mess my script, but it was the change in the jQuery version. I changed "live" to "on" and it works just like it did two days ago.
From now on I will link to a particular version instead of the latest:
(I apologize for the title for this thread. Don't know how it happened.)
Rion William...
All-Star
27656 Points
4574 Posts
Re: Object (button) doesn't support property (click)
Jan 17, 2013 12:54 AM|LINK