Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="onoffswitch">
- <%= check_box 'onoffswitch', '0', id:"myonoffswitch", class: 'onoffswitch-checkbox'%>
- <label class="onoffswitch-label" for="myonoffswitch">
- <div class="onoffswitch-inner"></div>
- <div class="onoffswitch-switch"></div>
- </label>
- </div>
- <%= link_to "switch",{controller: "static_pages", action: "local_switch"}, method: :post %>
- .onoffswitch {
- position: relative; width: 50px;
- -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
- }
- .onoffswitch-checkbox {
- display: none;
- }
- .onoffswitch-label {
- display: block; overflow: hidden; cursor: pointer;
- border: 50% solid #CCCCCC; border-radius: 22px;
- }
- .onoffswitch-inner {
- width: 200%; margin-left: -100%;
- -moz-transition: margin 0.2s ease-in 0s; -webkit-transition: margin 0.2s ease-in 0s;
- -o-transition: margin 0.2s ease-in 0s; transition: margin 0.2s ease-in 0s;
- }
- .onoffswitch-inner:before, .onoffswitch-inner:after {
- float: left; width: 50%; height: 5px; padding: 0; line-height: 5px;
- font-size: 16px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
- -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
- }
- .onoffswitch-inner:before {
- content: "";
- padding-left: 10px;
- background-color: #3498DB; color: #FFFFFF;
- }
- .onoffswitch-inner:after {
- content: "";
- padding-right: 10px;
- background-color: #CCCCCC; color: #FFFFFF;
- text-align: right;
- }
- .onoffswitch-switch {
- width: 20px; margin: -7.5px;
- background: #FFFFFF;
- border: 2px solid #CCCCCC; border-radius: 22px;
- position: absolute; top: 0; bottom: 0; right: 43px;
- -moz-transition: all 0.2s ease-in 0s; -webkit-transition: all 0.2s ease-in 0s;
- -o-transition: all 0.2s ease-in 0s; transition: all 0.2s ease-in 0s;
- }
- .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
- margin-left: 0;
- }
- .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
- right: 0px;
- }
- $("#myonoffswitch").change(function(){
- if ($(this).is(":checked"))
- {
- $.ajax({
- type : "POST",
- url : "/static_pages/local_switch", # add your correct url
- dataType: 'script',
- data : { id:2 }, #u can pass any no of data
- success : function(data){
- }
- });
- }
- else{
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement