Comments (4)
this should be all event based. we can fire a toggle event on the window tho:
element.addEventListener('toggle', function () {});
from ratchet.
This event also bubbles, so you can add it directly to the toggle element, or just bind to the body to catch all toggles.
element.addEventListener('toggle', function (e) {
console.log(e.target, e.detail.isActive);
});
i'm not crazy about the "isActive" name for whether you're toggling it to an on or off state… if you guys have a better name idea, i'd be open to that!
from ratchet.
SWEET
from ratchet.
Hope this helps someone else.
HTML
<input style="visibility:hidden" type="checkbox" value="1" checked="checked" id="user_remember_me">
<div class="toggle" data-matcher='user_remember_me'>
<div class="toggle-handle"></div>
</div>
JS
//Turns on toggle switches for any checked boxes
var active_ids = [];
$("input:checkbox(:checked)").each(function(){ active_ids.push($(this).attr("id")) });
$.each( active_ids, function( key, value ) {
$('div').find("[data-matcher='" + value + "']").addClass('active');
});
//Maps toggle changes to the hidden checkbox
$('.toggle').on('click', function() {
var inactive_ids = [];
$('.toggle').not('active').each(function(){ inactive_ids.push($(this).attr("data-matcher")) });
$.each( inactive_ids, function( key, value ) {
$('#' + value).prop('checked', false);
});
var active_ids = [];
$('.toggle.active').each(function(){ active_ids.push($(this).attr("data-matcher")) });
$.each( active_ids, function( key, value ) {
$('#' + value).prop('checked', true);
});
});
from ratchet.
Related Issues (20)
- Is there is any callback for modal ?? like slider and push HOT 7
- Issue with push.js HOT 18
- Ratchicons in the .tab-bar respond on 2nd tap
- push.js vs. pop.js
- Undefined Variable: "$chrome-color" on Line 13 HOT 1
- Question
- A Question
- your ratchet not working with phongap new cli 6.5,0 HOT 1
- How can i use ratchet in Angular4.0? HOT 1
- Custom HTML?
- Is it possible to make scroll content inside the app?
- New version? (discontinued) HOT 5
- Dead project: Latest commit on 21 Mar 2016
- Ratchet's icon cant display HOT 2
- Comeback Ratchet! HOT 5
- How to generate .apk file HOT 3
- Archive Ratchet?
- Is this project dead?
- readAsArraybuffer issue
- built-in grid system
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ratchet.