RailsCast 258 Token Fields bug with Rails 3.1
Posted: February 12, 2012 Filed under: Chapter 4 - Technology Leave a comment »Ryan Bates does a great RailsCast (as usual) of the jQuery TokenInput plugin from loopj. I had been able to get this plugin working in earlier versions of Rails/jQuery, but when I tried to integrate the plugin into my Rails 3.1 app I kept getting this error:
Uncaught TypeError: Object function (a,b){return new c.fn.init(a,b)} has no method ‘type’
I am not really sure what caused this error, and I could not find any information about the error on the web. I spent a couple of hours (ok, more like 6) fiddling with different things and comparing the working version to the non-working version. I was getting ready to throw it all out and try to proceed with Chosen from Harvest, but I decided instead to try the old “just delete the offending code” trick. So, I replaced this code online 139:
if($.type(url_or_data) === “string” || $.type(url_or_data) === “function”) {
With this code:
if(true) {//$.type(url_or_data) === “string” || $.type(url_or_data) === “function”
I am sure that this will blow something up at some point, but for now this works like a charm. If anybody has the proper way to do this, please post it in the comments (and I will update the post accordingly).
Thanks.
Matt