I saw comments in a previous question saying that it is best to use Prototype with Rails. However, my own experience is that Jquery is a superior Javascript library. Being new to Rails, I have not yet investigated how to use Jquery with Rails but I assumed this would work. Is it correct that this may be a problematic combination - especially in relation to Ajax - and that I may need to use Prototype instead?
I've worked on all my projects since 3 years with rails and (exclusively) jquery. Never really encountered any (serious) problems so far.
There is a plugin called jrails, which acts as a drop-in replacement for prototype.
http://github.com/aaronchi/jrails/tree/master
Update: with it you can get all of the same default Rails helpers for javascript functionality using
I use both jQuery and Prototype with rails. jQuery for DOM manipulation and thickbox (my favorite light box plugin), but i use prototype for AJAX right now. no particular reason, just haven't wanted to use the jrails plugin yet. im sure i will do this in the future. if you use both, this should be in your head tag:
<%= javascript_include_tag 'prototype' %>
<%= javascript_include_tag 'jquery' %>
<script type="text/javascript">
var $j = jQuery.noConflict();
</script>
Then use jQuery with $j
I use jQuery and Rails on the job in a production environment and have only nice things to say. We use AJAX too. The only problem I can think of is the jQuery.noConflict() call that's necessary if you're using jQuery and prototype together.
The only problem with jrails is rjs testing. But this patch adds 5 of 8 missing test helpers.
It won't be problematic to use jquery with rails at all, it's just not the natively supported JavaScript library. You don't actually have to use any of the JavaScript builtins in rails, and the (by default) RESTful structure of your application should make AJAX simple.
With prototype and scriptaculous, alot of the AJAX work has already been done for you. With jquery, you'll just be writing some more JavaScript yourself.
Rails was built to work with Prototype for AJAX et. al., but there's no reason you have to use Prototype. I'm a jQuery fan myself, and you can definitely use it with Rails.
You can still hook into a lot of the AJAX work that's been done in Rail with jQuery, not a problem.
And, as kmorris said, if you're using jQuery and any other javascript library on the same site, be sure to add the jQuery.noConflict() line in or else VERY bad things will happen.
Try this: https://github.com/xpepermint/js_erb
Javascript becomes part of app, i18n and js templating become available and more.
Related
I'm wondering what the following code is doing:
jQuery.Class("Vtiger_Helper_Js",{ });
I'm asking because I can't figure out what jQuery.Class is about...
The vtiger CRM uses the jQuery.Class plugin, available here.
You can see it in the repository in the libraries folder.
This is what is called jQuery.class.js which is a plugin to supersede prototype.js basically since jQuery is huge now.
Several of the methods in this plugin use code adapated from Prototype
Meaning they basically made jQuery and prototype.js one language to easily transition those who use prototype.js to jQuery or at least help thme
I was wondering what are the specific javascript libraries required to get the method => delete to work. Also, I'm having problems because I want to use the jquery library, and if I include :defaults it doesn't work. Is there a way to integrate the two?
Thank you.
jQuery can run in Rails if you include the UJS script. Your best option is to use the following:
https://github.com/indirect/jquery-rails
After reading some of the jQuery vs ext js questions here and google search result, my understanding is that ext js is a UI building library and jQuery is a more fundamental javascript framework. I've used jQuery for a while now. It's pretty cool but in general a better (much better) javascript.
So my question is: how easy is it to use jQuery for DOM navigation/manipulation and Ext.js for UI in the same project?
There is a page on jQuery website. But the demo is too simple and the external links to Ext.js are all dead.
I'm sure it's possible, but what sort of problems and challenges would I be facing?
You might be wondering why I want to do this. Well, the Ext.js set of UI just looks much better/more polished/more feature rich then jQuery UI. I'm particularly interested in the grid.
Thanks!
Using both libraries side by side is not an issue in the technical way (just add the jquery within a script-tag, that's it!). However, you should not use jQuery for ExtJS' stuff or vice versa. Well, unless you know exactly what you do.
The actual issue can be DOM manipulations (jQuery or ExtJS Core) outside of an ExtJS component that affect an existing component.
So, in a nutshell: You can use DOM manipulations when it will not affect the ExtJS components. Otherwise use the proper way within the component itself.
Well you dont need both the libraries to live together.. Extjs has DOM manipulation api too probably not as vast as jquery but it does have the basic stuff.
Coming to Jquery, jquery has UI building APIs too if not rolled into the library there are vast no of extensions for all kinds of problems. Just try googling whatever UI you are building now with respect to jquery and you will find a library for sure.. There is jquery templates too that lets you generate HTML markup from a template defined by you and applying data objects (json) to it.. Jquery has a vast community too so most of your questios or concerns will be addressed by the community almost instantly..
So yea my suggestion would be to choose one library and stick to it and contribute to the library if there are many missing features..
Lastly I would suggest you choose Jquery.. It rocks.. period..
I think you would have no problem do this stuff... Make Ext.js your main jQuery library and jQuery as the data manipulation library for the DOM.
There would be no problem or conflicts because jQuery is compatible with other javascript libraries.
I am trying to use Jquery / ajax in rails 3.0.7. I do not understand what is the current situation about Jquery and rails.
Everywhere there is tons of hacks and plugins and scripts to use JQuery. So :
Is there an "official way" to use jquery in rails 3.0.x or are all method just customs hacks?
Is there a rjs or equivalent with Jquery for rails 3.0.x ?
What are all those jquery something files for rails, when jquery official site only propose one file?
From what i saw protoype is easy to use for ajax, why is it dropped in favor of jquery for rails 3.1.x?
As of Rails 3, the JavaScript library you use is up to you. There are "drivers" created for the Rails primitives for Prototype and for jQuery. To set up jQuery, simply include the jquery-rails gem in your bundle file:
gem "jquery-rails"
...then run bundle install.
If you don't already have jQuery installed in the project, you can run this command to install it:
rails generate jquery:install
In Rails 3.1, jQuery is the default, rather than Prototype. I personally believe it's because jQuery plays well with other JavaScript libraries, and that flexibility makes it more appealing to something like Rails. However, there are tons of arguments on all sides. I'm not sure if there's a definitive reason besides "jQuery is the new hotness."
I believe Ext.js was using jQuery, but I'm not sure. Does anyone know if there is full compatibility with jQuery and Ext.js?
Ext.js is completely independent of jQuery and as such does not rely on jQuery in any way. Don't know what you mean by 'full compatibility' but you can use both on the same page as they don't interfere with each other.
As Ext.js doesn't use the $-function, you don't even have to do any special trickery to get them to work together, as is the case with using Prototype with jQuery, for example.
You should be able to find some answers on the jquery site where it talks about using jQuery with other libraries.
Hope this helps some.
For ExtJS 3 for example, you need to follow a given loading order for these libraries AND load the ExtJS jQuery adapter.
See http://www.extjs.com/learn/Ext_Getting_Started for details :
jQuery (1.1+) jquery.js
jquery-plugins.js // required jQuery plugins
ext-jquery-adapter.js
ext-all.js (or your choice of files)
I think jQuery (core) and ExtJS are very compatible. I prefer to start new projects using both; in fact, flot.js demands jQuery - and flot.js is very nice - so in nearly every project I use both jQuery and ExtJS. Go for it!
Though ExtJS has made strides in their DOM manipulation and traversal utilities (core), nothing beats the elegance of jQuery (core). However, I prefer ExtJS (UI) to jQuery UI; I find it is much more homogeneous (and capable) than jQuery UI.
Upto Extjs 3.XX, adapters were configurable.
But Sencha (Ext4) onwards, there is no separate adapters, instead we have ExtCore.
No more other libraries
ExtJS used to be built on top of other libraries. With version 2 they had their own but still offered the possibility to use other libs. But not anymore with version 3. ExtJS core code is very very mature, very efficient and VERY tidy. If you ask me, their code is written a lot better than jQuery's but that's subjective.
Combine with jQuery with no tricks
Anyway. If you intend to use ExtJS but would like to use other libs as well you can still do that. But if you think that you'd rather use jQuery with ExtJS I suggest you don't do that, because your code will have many hacks to overcome differences. I would rather use just ExtJS. You'll like it and probably won't want to switch back anymore.