Submitting Forms with the Switch Component
November 10, 2017 at 4:56 pmPosts: 1Member Reply #12475
I have been playing with the new v5 demo and the one thing I can’t figure out (which was the same with v4 and the Material controls) is how you get the switch/checkbox state. When I implement these controls on a page, jQuery always says they aren’t checked and they don’t submit to the server (ASP.NET), even though they are toggled. I’m obviously missing something simple here, but I can’t figure it out.
Here is the demo: http://keenthemes.com/metronic/preview/index.php?page=components/forms/controls/switch&demo=default. How do I get the current state of the “With Icon” demo in the second column of the first portlet? I tried adding an ID to it via Chrome’s inspection tools and using jQuery, but it always tells me it’s unchecked.
November 14, 2017 at 5:46 pmPosts: 4527Support Staff Reply #12600
You can change the checkbox state using jQuery’s prop method using it with the checkbox ID:
The above code will change the actual checkbox’s state and you will be able to submit it.
If you need any further help please let us know.
November 14, 2017 at 6:19 pmPosts: 1Member Reply #12605
But how do we go about using this checkbox without that? If I flip it and it doesn’t check the underlying checkbox, then it’s a fancy UI that doesn’t really do anything. Or, is there some kind of event when that is flipped that fires so jQuery can be used to check the actual checkbox?
November 16, 2017 at 8:43 pmPosts: 4527Support Staff Reply #12678
We have just double checked it and the manually checked checkbox/radios are submittable with normal form submit.
Can you try to debug your form submit by dumping the entire POST variable ? Or you are able to submit standard checkbox/radio but the Metronic ones ? But according to our testing the checkboxes/radios are working as expected.
September 27, 2018 at 4:29 amPosts: 1Member Reply #19653
I have the same problem, if there is no event attached to event change in m-switch component, this is a beautiful but useless component.
Should be a event attached to the changes in the switch to update the value of the checkbox previous to be submited. This component is pure css? no JS/jquery ?
January 31, 2019 at 8:17 amPosts: 3Member Reply #19882
I don’t think it useless.
I use capturing event by Jquery by css class and now this switch disapeared in metronic, and the new one it’s worst in my opinion.
You must be logged in to reply to this topic.