JQuery + rails problem - ruby-on-rails

I'm new to JQuery and so far I'm using prototype. But now I want to use JQuery and the thing is I done want to change my old code, which uses prototype
I installed jrails plugin also
my question is can i use
new Ajax.Updater etc.. kind of methods with JQuery (having the jrails plugin installed)
(it doesnt work for me)
BTW - I'm getting JQuery from here
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
thanks in advance
cheers
sameera

I'm not sure if I understand your question completely but it seems to me that you are asking if you can use both Prototype and jQuery because you don't want to have to change all your old code. The best thing to do would be to put jQuery in noConflict mode. Under your inclusion of the jquery file from google, just do this:
<script>
var $j = jQuery.noConflict();
</script>
That way jQuery won't step on Prototype's toes. instead of calling jQuery with a $ you'd use $j for example:
$j('#sidebar').hide();
I hope that helps... if indeed that's what you were asking.

I found that jrails was acting strange for me a few weeks ago. I discovered that the gem version solved my problems. Try installing it as a gem (if you're currently running it as a plugin) and see what happens.

Related

does scriptaculous still have Javascript hacking vulnerability?

Scriptaculous is listed with the Javascript Hacking vulnerability in the following site:
[http://nvd.nist.gov/view/vuln/detail?vulnId=CVE-2007-2384]
Does any know if this has been resolved since the article was posted in 2008?
I think the vulnerability of Scriptaculous was due to Prototype js 1.6.
https://security-tracker.debian.org/tracker/CVE-2007-2383
If u want to use scriptaculous without vulnerability u have to replace the prototype js file in the scriptaculos with the latest prototype js version. The latest today I think is 1.7.3

Globalize.js API changes and jQuery UI

I'm trying to play with the examples from jQuery UI, such as this one. I would like to use the globalization functions (for a currency field, for example), but it seems that Globalize.js has gone through a major API change, so that the code used in the UI examples doesn't work with the Globalize version I downloaded. For example, the jQuery UI depends on a Globalize.parseFloat function that doesn't exist in that version.
So apparently jQuery UI uses a legacy version of Globalize.js, but how should I download it? I couldn't find any information on that, neither on the API changes. I could download the JS files that are included by jQuery UI, obviously, but I was hoping for a "more official" solution.
I can confirm that the Globalize 1.0.0-alpha releases are incompatible with the current jQuery UI 1.11.x releases. I have successfully used Globalize 0.1.1 with jQuery UI 1.11.x.
This blog post from jQuery UI indicates that they are "...working on a full rewrite of the datepicker widget. The rewrite will feature a far simpler API that will make customizations a lot easier. The rewrite builds on top of the rewritten Globalize library, which builds on top of CLDR, a comprehensive source for globalization data.". Hopefully, this rewrite will include more than just datepicker!
It's 2016 already, two years later, but jQuery 1.11.x is still current (v1.12 in BETA). And I ran into this same issue for a brown-field project I'm doing. I managed to solve this thanks to the OP's analysis that jQuery UI indeed assumes the legacy Globalize version, and the solution of #wedgef5 to switch back to v0.1.1 of Globalize.
The OP did ask for an official answer. I guess there is none, but current best practice is to use a package manager. I use Bower which downloads the current version (now v1.1) by default. Assuming you did the same, you fix this in Bower as follows:
bower uninstall globalize --save
bower install globalize#0.1.1 --save
If you use a different package manager, something similar applies. After this code similar to this example works :). Your bower.json should be changed:
{
"name": "yourpackage",
...
"dependencies": {
...
"globalize": "0.1.1" // Used to be: "globalize": "^1.1.1"
...
}
...
}
Have you tried going to the releases tab in the globalize github project? You can cross-reference the release dates of globalize and jQueryUI and make your best guess from there.

Should bootstrap.js run after jquery.js or before?

I want use both jquery ui and bootstrap , there is a solution
jquery-ui-bootstrap
and you must load bootstrap before jqueryui, if you won't there will apear something wrong . eg: Bialog buttons will be lose style.
but there is another error when you use radio-button if you load bootstrap before jquery.
another question about this
so? Should bootstrap.js run after jquery.js or before?
I'm pretty sure you should load jQuery first because Bootstrap uses jQuery features.
I tried to load jquery.js first, and my code is runing propertly. Try it and tell us the result, otherwise, we don't know how to help you...

JQuery UI with Primefaces

I have some old code that uses Primefaces 2.2.1 but I now that I need to upgrade the version to 3.1.1 to use some of the new features, some of my javascript functionality is breaking.
I tracked down the issue and realized that in 2.2.1, the jQuery UI plugin was included out of the box but for some reason it is missing in 3.1.1.
Does anyone know why this happened and how can I get my javascript to function correctly without changing it?
I have fixed the original problem posed by this question by downloading the jQuery UI plugin and including manually.

Determine if app uses prototype js?

Im taking over an app that was started by someone else. I want to use jquery, but from what i read, the only way to use it replaces Prototype. This shouldnt be a problem, but im not sure if the project uses any protoype. Is there a plugin i can run or something that searches the project and checks compatibility without prototype?
I am not aware of any. The only way I can think of doing it would be to make the change and hunt for errors then translate them to JQuery. Most are not hard. They are usually just slight differences like addClass instead of addClassName
You can use both prototype and jquery, using jquery's NoConflict mode. You can also look at the jquery-rails plugin that removes prototype and reimplements the helpers using jquery.

Resources