Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:07:13+00:00 2026-06-05T01:07:13+00:00

I am using rails with jquery gem. I have the following in my application.js

  • 0

I am using rails with jquery gem.

I have the following in my application.js

//= require jquery
//= require jquery_ujs
//= require_tree .

Do these declarations include files in order ?

I am using a jquery pluging textareaexpander (http://www.sitepoint.com/blogs/2009/07/29/build-auto-expanding-textarea-1/)

I am getting a js error

jQuery("textarea[class*=expand]").TextAreaExpander();

on almost the last line of the plugin which is something like below

// initialize all expanding textareas
jQuery(document).ready(function() {
  jQuery("textarea[class*=expand]").TextAreaExpander();
})

I don’t get it ? is it because jQuery hasn’t been loaded. why is TextAreaExpander still not defined ?

For reference below is the rest of the code in the plugin file.

(function($) {
// jQuery plugin definition
$.fn.TextAreaExpander = function(minHeight, maxHeight) {
var hCheck = !($.browser.msie || $.browser.opera);
// resize a textarea
function ResizeTextarea(e) {
// event or initialize element?
e = e.target || e;
// find content length and box width
var vlen = e.value.length, ewidth = e.offsetWidth;
if (vlen != e.valLength || ewidth != e.boxWidth) {
if (hCheck && (vlen < e.valLength || ewidth != e.boxWidth)) e.style.height = "0px";
var h = Math.max(e.expandMin, Math.min(e.scrollHeight, e.expandMax));
e.style.overflow = (e.scrollHeight > h ? "auto" : "hidden");
e.style.height = h + "px";
e.valLength = vlen;
e.boxWidth = ewidth;
}
return true;
};
// initialize
this.each(function() {
// is a textarea?
if (this.nodeName.toLowerCase() != "textarea") return;
// set height restrictions
var p = this.className.match(/expand(\d+)\-*(\d+)*/i);
this.expandMin = minHeight || (p ? parseInt('0'+p[1], 10) : 0);
this.expandMax = maxHeight || (p ? parseInt('0'+p[2], 10) : 99999);
// initial resize
ResizeTextarea(this);
// zero vertical padding and add events
if (!this.Initialized) {
this.Initialized = true;
$(this).css("padding-top", 0).css("padding-bottom", 0);
$(this).bind("keyup", ResizeTextarea).bind("focus", ResizeTextarea);
}
});
return this;
};
})(jQuery); 

// initialize all expanding textareas
jQuery(document).ready(function() {
jQuery("textarea[class*=expand]").TextAreaExpander();
}); 

As you can see the function TextAreaExpander was first defined by extending jQuery and then called on document ready but still not working. I have similar issues with other plugins on of them is chosen.js.

If any one can point out the issue and elaborate what is causing this, because for me this doesn’t make any sense ( but obviously i am missing a point here).

Relevant code

development.rb

config.assets.compress = false
config.assets.debug = true

application.rb
config.assets.enabled = true
config.assets.version = '1.0

Ok so I did the experiment suggested to check if it is a syntax issue, turns out it isn’t.

I did another experiment, If I remove the line

//= require_tree .

from application.js and instead replace it with

//= require_self

and in my view file (the view that is being rendered) I add the following at the end

= javascript_include_tag 'libs/jquery.textarea-exapander'

all seems to work perfectly. Any ideas now ?

more info

app/assets/javascript
  |- application.js
  |- chosen.jquery.js
  |- admin/
     |- categories.js.coffee
  |- libs/
     |- jquery.textarea-exapander.js
     |- modernizr.js
     |- platformselector.js
     |- waypoints.js
  |- gmaps4ails/
     |- gmaps4rails.base.js
     |- gmaps4rails.bing.js
     |- gmaps4rails.googlemaps.js

my application.js

//= require jquery
//= require jquery_ujs
//= require_tree .

code from my layout

%html
  %head
    %title Whatever
    %link{type:"text/css",rel:"stylesheet", href:"http://fonts.googleapis.com/css?family=Abel"}
    = stylesheet_link_tag    "application", :media => "all"
    = stylesheet_link_tag 'gmaps4rails'
    = javascript_include_tag "application"
    = csrf_meta_tags
  %body
    = render 'shared/header'
    %div#main.inside.topadd
      = yield
      %div.wrapper
    =render 'shared/footer'
    = yield :scripts

The above setup does not work

The following setup works

my application.js

//= require jquery
//= require jquery_ujs

inside my registrations/new.html.haml

some bla bla bla bla haml code

= javascript_include_tag 'libs/jquery.textarea-exapander'

this works, the same is true for the other plugin chosen.js if I include in after the view it works otherwise it gives the same error that .chosen is not a function.

So as from the comments it looks like something is wrong with my local setup

I have noticed another strange thing in the html on heroku and local

this is the body class on heroku

linux js gecko gecko_20100101 firefox firefox_12_0 firefox_12 gecko_12_0

but on my local the body class is

js no-flexbox canvas canvastext webgl no-touch geolocation postmessage no-websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients no-cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths linux gecko gecko_20100101 firefox firefox_12_0 firefox_12 gecko_12_0 js flexbox canvas canvastext webgl no-touch geolocation postmessage no-websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients no-cssreflections csstransforms csstransforms3d csstransitions fontface video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths

I am also seeing this my every rails app locally

<div id="cboxOverlay" style="display: none;"></div>
<div id="colorbox" class="" style="padding-bottom: 0px; padding-right: 0px; display: none;"></div>

after body starts and

<div id="supersized-loader"></div>
<div id="supersized"></div>

before body ends
I am not using neither including color box by far…

What is going on ??

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:07:15+00:00Added an answer on June 5, 2026 at 1:07 am

    Figured it out after hours. The issue was not where all of us were looking for it.

    I had nginx running on my local machine, the conf of which was pointing to another project of mine and the public directory was set to that project, so the path /assets/application.js was being served by nginx directly from the public/assets/ directory of the other project. and since the other project was on heroku I used to precompile assets locallay so a compiled application was js was created inside app/assets which was being served.

    Thanks a lot for your help guys, Your comments and discussion helped me figure out that the issue was with local machine only and that something bad was going on with my configuration.

    Thanks again

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such problem: I'm using rails, devise gem and jQuery validation plugin. I
Using Ruby 1.8.7-p358, Rails 3.0.12, gem responder, gem simple-form; jquery_ujs.js I have a form
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
I have jquery working on my Rails app using the gem 'jquery-rails' . I
I'm using auto_complete plugin: https://github.com/crowdint/rails3-jquery-autocomplete I have installed the gem and added require line
I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is
I'm using the jquery-ui-rails gem. It works fine on local host, but when I
I'm using rails, but doing all my Javascript unobtrusively using jQuery in application.js .
Using: jquery3-autocomplete gem at 1.0.5 jquery-rails gem at 1.0.19 mysql2 gem at 0.2.7 The
I have a new application starting that's using Rails 2.3.8 for stability concerns and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.