I am using Best In Place gem 3.03.
My view Page code:
<div class="container">
<h3> Name</h3>
<%= best_in_place #contact, :first_name %>
</div>
My coffee script :
users.coffee
jQuery ->
$('.best_in_place').best_in_place()
The First Name is coming as Mark or any Name that is in the Database but when I click it the input field is not displaying allowing me to edit the text.
application.js
//= require jquery
//= require jquery_ujs
//= require dropzone
//= require jquery.purr
//= require best_in_place
//= require best_in_place.purr
//= require_tree .
I found the Issue looks like I was including the jquery script twice one in application.js and once using javascript include tag.
Related
I have the following field
<%= f.collection_select :tag_list, #tags.order(:name), :id, :name, {}, { class: 'select2', multiple: true } %>
I have added the select2-rails gem and have added the js and css in the respected files
//= require select2-full application.js
*= require select2 application.css
I have also added the following to my application.js file
$(document).ready(function() {
$('.select2').select2();
});
However, I'm getting the following
Won't even dropdown.
Rendered HTML
<select class="select2 hasCustomSelect" multiple="multiple" name="contact[tag_list][]" id="contact_tag_list" style="appearance: menulist-button; position: absolute; opacity: 0; height: 33px; font-size: 13px; width: 1563px;">
<option value="28">ANFIM</option>
<option value="11">BWT filter</option>
...
</select>
When adding the select2 js in the application.js I also get this
app.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery.min
//= require jquery_ujs
//= require prototype
//= require moment.min
//= require fullcalendar
//= require lib_ext
//= require BigDecimal-all-1.0.1.min
//= require dialog
//= require widgets
//= require classes
//= require payroll
//= require account_context_menu
//= require plan_table
//= require requirements
//= require help
//= require help_data
//= require jquery.contextMenu.js
//= require jquery.treetable
//= require jquery.jstree
//= require select2-full
//= require plugins
//= require scripts
//= require additional
//= require effects
//= require clusterize.min
//= require consolidated_orders
//= require sales_invoices
//= require main
//= require journals/auto_reversal
//= require budgets/new
//= require budgets/export
$(document).ready(function() {
$('.select2').select2();
});
try running
$(function() {
$('.select2').select2();
});
$(document).ready have been removed in jquery3
I could not reproduce the issue, I have the same libraries as you and imported css assets aswell, except that I have //= require jquery instead of //= require jquery.min but should not be a problem try running $('.select2').select2(); directly in your js console and see if it works - if so it looks like you have a problem with your jquery ready function
I am using the Flexslider 2 Rails Gem from https://github.com/constantm/Flexslider-2-Rails-Gem.
As informed in documentation, I called the JS and CSS, but only the CSS is not loaded (yes, JS works).
ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin11.0]
rails -v: Rails 4.2.1
flexslider version: flexslider 2.2.0
My app/assets/stylesheets/application.css
*= require pineapple
*= require font-awesome
*= require dropzone/basic
*= require application/style
*= require fancybox
*= require flexslider.css
PS.: I tried require flexslider (without extension) too.
My app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require jquery.slimscroll.min
//= require pineapple
//= require tinymce
//= require dropzone
//= require jquery-ui/sortable
//= require jquery-ui/effect-highlight
//= require jquery-ui/tooltip
//= require jquery.mjs.nestedSortable
//= require general
//= require maskedinput
//= require fancybox
//= require jquery.flexslider
My HTML (I stripped others li tags here, but is the same)
<div id="carousel0" class="flexslider carousel">
<ul class="slides">
<li>
<%=link_to '/page/dynamic' do %>
<%=image_tag image_path('show-case-1.jpg'), alt: 'Show Case', title: 'Show Case', class: 'img-responsive' %>
<%end%>
</li>
</ul>
</div>
My custom .JS
$('#carousel0').flexslider({
animation: 'slide',
itemWidth: 300,
itemMargin: 100,
minItems: 2,
maxItems: 4,
pauseOnHover: true,
slideshowSpeed: 8000
});
There are no console errors.
Thanks for your help.
You are only including the library and providing the markup. But you don't "Hook up the slider". See step 3 https://www.woothemes.com/flexslider/
Have you tried:
*= require flexslider.sass
Shot in the dark after looking through the gem you're using
[SOLVED]
My app has some "specific pages". The app has multiple sites independent each other.
In my app/assets/stylesheets folder and app/assets/javascript folder I have 1 more CSS and JS beyond the application.(JS|CSS)
There are sitetype.css AND sitetype.js.
I called require flexslider.css in sitetype.css AND //= require jquery.flexslider in sitetype.js and it works.
Thanks all for the help.
How to perform this piece of lightbox code using rails link_to method
<img src="img/bmw.jpg">
the image_tag outputs images well
image_tag(#ad.photo.url(:medium))
so how to use this image_tag with link_to so lightbox works?
my application.js
//= require jquery
//= require jquery_ujs
//= require foundation
//= require lightbox
//= require turbolinks
//= require_tree .
$(function(){ $(document).foundation(); });
and my application.css is
*= require_tree .
*= require_self
*= require foundation_and_overrides
*= require lightbox
*= require mystyle
*/
link_to image_tag(#ad.photo.url(:medium)), #ad.photo.url(:original), data: { lightbox: "cars", title="MyCaption" }
Breakdown: The first image_tag is your thumbnail, and the second, is your original image which will be shown in the modal generated by lightbox.
Btw: That is Slim syntax.
Working code after debugging:
link_to image_tag(#ad.photo.url(:medium)), image_path(#ad.photo.url(:medium)), data: { lightbox: "cars", title="MyCaption" }
Hi i want to give date and time as input in rails. so i used datetimepicker in app. here is the link i had followed to use datetimepicker. but i am not able to see datetimepicker in my input field. what will be the mistake? where i am struggling? please advise me if you have ideas
https://github.com/lubieniebieski/bootstrap-datetimepicker-rails
here is my application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require switchery
//= require moment
//= require bootstrap-datetimepicker
//= require_tree .
here is my application.css
*= require_tree .
*= require_self
*= require switchery
*= require bootstrap-datetimepicker
here is my form.html
<tr>
<td class="col1"><label for="exam_date">Exam Date</label></td>
<td class="col2">
<%= text_field_tag :test_date%>
</td>
</tr>
here is my js
$(function() {
$('#test_date').datetimepicker();
});
Please help me to get out from this problem. tried a lot but could not find where i am struggling. it might be repeated. but i refered So before posting. so pls dont do downvoting. thanks in advance.
Most likely this bootstrap-datetimepicker plugin has a dependency on bootstrap.js.
Update your application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require switchery
//= require moment
//= require bootstrap
//= require bootstrap-datetimepicker
//= require_tree .
I'm trying to get this done for quite some time now and i can't figure out whats wrong:
My Link:
<%= link_to '#', tag, class: "tag-tooltip",
:data => {:toggle=>"tooltip"},
'data-original-title' => "Hey Whats up",
'data-placement' => 'right'%>
My Javascript:
$('.tag-tooltip').tooltip();
But it's not working... What am i missing ?
EDIT
If i go into my Chrome Console and insert ($('.tag-tooltip').tooltip();) it is working.
So i guess the js file is not loading ? (I checked my application.js and i'm requiring everything.)
I found out the wrapping which worked:
$(document).on("ready page:change", function() {
$('.tag-tooltip').tooltip();
});
Update:
$(document).on("turbolinks:load",function(){
$('.tag-tooltip').tooltip();
})
With vanilla JS
document.addEventListener("turbolinks:load", function() {
$('.tag-tooltip').tooltip();
});
In my case the problem was that I was loading jquery-ui after bootstrap-sprockets
In my application.js I changed:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require jquery-ui
to
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require turbolinks
//= require bootstrap-sprockets
Then it all started working as it should.
You need to add some script in your code :
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip(
{container:'body', trigger: 'hover', placement:"right"}
);
});