manuelvanrijn / bootstrap-switch-rails Goto Github PK
View Code? Open in Web Editor NEWA small gem for putting bootstrap-switch into the Rails asset pipeline
License: MIT License
A small gem for putting bootstrap-switch into the Rails asset pipeline
License: MIT License
I installed your gem, no errors.
Then I included //= require bootstrap-switch
on application.js
, as you instructed, and my rails app stopped working saying: "couldn't find file 'bootstrap-switch' (in .../app/assets/javascripts/application.js:17)
A similar error shows up if I make a similar edit on application.css
.
Why can't rails find the files? Shouldn't the gem take care of it?
After I @import "bootstrap2-switch"
I get this:
File to import not found or unreadable: bootstrap2-switch.
Load paths:
/home/.../Documents/.../app/assets/images
/home/.../Documents/.../app/assets/javascripts
/home/.../Documents/.../app/assets/stylesheets
/home/.../Documents/.../vendor/assets/javascripts
/home/.../Documents/.../vendor/assets/stylesheets
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/turbolinks-1.1.1/lib/assets/javascripts
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/jquery-rails-3.0.4/vendor/assets/javascripts
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/coffee-rails-4.0.1/lib/assets/javascripts
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/font-awesome-rails-4.0.3.1/app/assets/fonts
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/font-awesome-rails-4.0.3.1/app/assets/stylesheets
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/images
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/javascripts
/home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets
/home/.../Documents/rails_projects/vendor/assets/stylesheets
Switch's folder is not even listed... however bundle show bootstrap-switch-rails
returns /home/.../.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/bootstrap-switch-rails-2.0.2
, so it is installed.
I am trying to use the gem with Rails 4 this way
<div class="col-sm-9">
<%= f.check_box :allow_read, :data => { :size=>'medium', 'on-color'=>'success', 'on-text'=> "#{t('yes').upcase}", 'off-text'=> "#{t('no').upcase}" } %>
</div>
The generated HTML is weird , the OFF text is displayed on the left side of the switch with translated on/off texts ..
<div class="col-sm-9">
<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-off bootstrap-switch-medium bootstrap-switch-animate">
<div class="bootstrap-switch-container">
<span class="bootstrap-switch-handle-on bootstrap-switch-success">ON</span>
<label class="bootstrap-switch-label"> </label>
<span class="bootstrap-switch-handle-off bootstrap-switch-default">OFF</span>
<input name="permission[allow_read]" type="hidden" value="0">
</div>
</div>
<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-on bootstrap-switch-medium bootstrap-switch-animate bootstrap-switch-id-permission_allow_read">
<div class="bootstrap-switch-container">
<span class="bootstrap-switch-handle-on bootstrap-switch-success">OUI</span>
<label class="bootstrap-switch-label"> </label>
<span class="bootstrap-switch-handle-off bootstrap-switch-default">NON</span>
<input data-size="medium" data-on-color="success" data-on-text="OUI" data-off-text="NON" type="checkbox" value="1" checked="checked" name="permission[allow_read]" id="permission_allow_read">
</div>
</div>
</div>
It looks like they have updated to 1.4:
https://github.com/nostalgiaz/bootstrap-switch/blob/master/static/js/bootstrap-switch.js#L2
I've got following errors:
Unknown property 'user-select'. Declaration dropped. bootstrap3-switch.self-eca58a24352b32df1ad2218f1a4561a9a8d00ae4825c407a57df83d56f54fb85.css:37
Expected 'none', URL, or filter function but found 'alpha('. Error in parsing value for 'filter'. Declaration dropped. bootstrap3-switch.self-eca58a24352b32df1ad2218f1a4561a9a8d00ae4825c407a57df83d56f54fb85.css:145
Expected 'none', URL, or filter function but found 'alpha('. Error in parsing value for 'filter'. Declaration dropped.
..when using bootstrap-sass 3.2 with bootstrap-switch-rails (3.3.3)
Any ideas what this might be?
I've started getting the following warning when I use your gem.
DEPRECATION WARNING: Extra .css in SCSS file is unnecessary. Rename /usr/local/rvm/gems/ruby-2.2.5/gems/bootstrap-switch-rails-3.0.0/vendor/assets/stylesheets/bootstrap3-switch.css.scss to /usr/local/rvm/gems/ruby-2.2.5/gems/bootstrap-switch-rails-3.0.0/vendor/assets/stylesheets/bootstrap3-switch.scss. (called from _app_views_layouts_blank_html_erb__1211379351604111721_92167400 at /home/ubuntu/workspace/law_dasher/app/views/layouts/blank.html.erb:5)
Hi,
do you plan to release a new version for this gem? This would remove the deprecation warnings already fixed in master.
Is there any updates on bootstrap 4 styling compatibility?
It appears that bootstrap-switch does not play nicely with turbolinks. I needed to disable turbolinks to utilize bootstrap-switch. Is there any workaround to utilizing this with turbolinks, or would this require a fork of bootstrap-switch that listens for turbolink events?
Can you clarify the correct settings to use for Bootstrap 4?
Seems like I can only switch css between bootstrap2 and bootstrap3, do I use bootstrap3-switch for bootstrap4 or something different?
application.js
//= require bootstrap-switch
application.scss
@import "bootstrap3-switch";
I am applying bootstrap switch with options like this
$('#switch-state').bootstrapSwitch('setSizeClass', 'switch-mini');
its throwing this error
Uncaught TypeError: Cannot read property 'apply' of undefined
I'm getting the following error from the sass compiler in my Rails 4.1 beta-1 project. Anybody have any suggestions?
Invalid CSS after "...0 8px rgba(red(": expected ")", was "@btnPrimaryBack..."
Hello,
I installed this gem following the README. I included bootstrap-switch in my SASS stylesheets using the "import" statements as described there (btw, the statements include semicolons; didn't SASS get rid of semicolons?!).
@import "bootstrap3-switch"
This leads to the following error message (development mode):
Sass::SyntaxError
...
File to import not found or unreadable: bootstrap3-switch.
Load paths:
...
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/bootstrap-switch-rails-3.3.2/vendor/assets/javascripts
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/bootstrap-switch-rails-3.3.2/vendor/assets/stylesheets
...
However, when I use the CSS import
*= require bootstrap3-switch
there is no error message and the CSS file gets loaded (from the produced HTML):
<link data-turbolinks-track="true" href="/assets/bootstrap3-switch.self.css?body=1" media="all" rel="stylesheet" />
So I guess there is something wrong with the SASS import.
I identified the problem and found a solution.
Problem: the SASS import filename
statement tries to import "_filename.scss".
Solution: use import "bootstrap3-switch.css.scss"
in your application.css.sass
You should update the README or change the files to "_bootstrap3-switch.scss".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.