Corrado Lembo
asked on
JAVASCRIPT Switchers PLUGIN fail postback
I'm editing an ASP.NET template that includes the use of JQUERY Switchery plugin to show stylized checkbox.
My project also includes the use of MasterPage.
I need to run code when the state of the checkbox control change, and for this reason I have activated the control property AutoPostBack = TRUE
Unfortunately, because of the Switcher plugin changes the screen state of the control but does not trigger server event , I cannot execute code behind.
There is a way to fire event when checkbox change state using this plugin?
This is my checkbox in asps page:
<asp:CheckBox runat="server" ID="chkModality" data-plugin="switchery" data-color="#f05050" Style="float:left;padding- right:20px " AutoPostBack="true" />
This is javascript code in core.js file
Components.prototype.initS witchery = function() {
$('[data-plugin="switchery "]').each( function (idx, obj) {
if ($(this).prop("tagName") == "SPAN" && $(this).find("input[type=c heckbox]:f irst").pro p("tagName ") == "INPUT") {
var chk = $(this).find("input[type=c heckbox]") ;
new Switchery(chk[0], $(this).data());
} else {
new Switchery($(this)[0], $(this).data());
}
});
},
How I can do it?
My project also includes the use of MasterPage.
I need to run code when the state of the checkbox control change, and for this reason I have activated the control property AutoPostBack = TRUE
Unfortunately, because of the Switcher plugin changes the screen state of the control but does not trigger server event , I cannot execute code behind.
There is a way to fire event when checkbox change state using this plugin?
This is my checkbox in asps page:
<asp:CheckBox runat="server" ID="chkModality" data-plugin="switchery" data-color="#f05050" Style="float:left;padding-
This is javascript code in core.js file
Components.prototype.initS
$('[data-plugin="switchery
if ($(this).prop("tagName") == "SPAN" && $(this).find("input[type=c
var chk = $(this).find("input[type=c
new Switchery(chk[0], $(this).data());
} else {
new Switchery($(this)[0], $(this).data());
}
});
},
How I can do it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you check the following:
1. Verify the function I posted above is wrapped inside document ready.
2. Add a console.log("hello world"); as the first line inside that function I gave above. Run your page, click the checkbox and check F12 console to see if "hello world" appears.
1. Verify the function I posted above is wrapped inside document ready.
2. Add a console.log("hello world"); as the first line inside that function I gave above. Run your page, click the checkbox and check F12 console to see if "hello world" appears.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what a difference with
$('#<%=chkModality.ClientI D%>').chan ge( function() {
or
$('#<%=chkModality.ClientI D%>').on(" change", function() {
$('#<%=chkModality.ClientI
or
$('#<%=chkModality.ClientI
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If your question has been answered, you can close it and select the comment(s) that provided your solution.
ASKER