Hello,
I'm starting in rails and ajax. So i've a javascript question:
someone could help me to update the class of a div?
Regards. 8 11833
On 14 Mar, 00:35, "Jean-Sébastien" <jeansebastien....@gmail.com>
wrote:
Hello,
I'm starting in rails and ajax. So i've a javascript question:
someone could help me to update the class of a div?
Regards.
<html><body>
<div id="div_id"></div>
<style type="text/css">
..wow
{
border: 2px dashes red;
}
</style>
<script type="text/javascript>
var d = document.getElementById('div_id');
d.className += ' wow';
</script>
</body>
It hasn't anything to do with rails or ajax though, for that you will
use the rails helper scriptaculous.
On Mar 13, 7:35 pm, "Jean-Sébastien" <jeansebastien....@gmail.com>
wrote:
Hello,
I'm starting in rails and ajax. So i've a javascript question:
someone could help me to update the class of a div?
document.getElementById("myDiv").className = "newClass_name";
>
Regards.
"Jean-Sébastien" <je***************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Hello,
I'm starting in rails and ajax. So i've a javascript question:
someone could help me to update the class of a div?
You use the className property of the element's instance. For example:
..c1 { background-color: purple; }
..c2 { color: red; }
<div id="d1">...</div>
document.getElementById('d1').className = 'c1';
Do not forget though, that the className property *replaces* it's value when written to.
Therefore if you would like to stack classes, you would need to:
document.getElementById('d1').className = 'c1';
document.getElementById('d1').className += ' c2';
Notice the plus and the space in the string literal.
-Lost
On Mar 14, 11:46 am, "shimmyshack" <matt.fa...@gmail.comwrote:
On 14 Mar, 00:35, "Jean-Sébastien" <jeansebastien....@gmail.com>
wrote:Hello,
I'm starting in rails and ajax. So i've a javascript question:
someone could help me to update the class of a div?
Regards.
<html><body>
<div id="div_id"></div>
<style type="text/css">
.wow
{
border: 2px dashes red;}
</style>
<script type="text/javascript>
var d = document.getElementById('div_id');
d.className += ' wow';
</script>
</body>
It hasn't anything to do with rails or ajax though, for that you will
use the rails helper scriptaculous.
Not Scriptaculous, Prototype.js's addClassName and removeClassName
methods:
$(id).addClassName('blah');
However, other frameworks can be used with Rails, e.g. Fork's addClass
and removeClass:
<URL: http://www.forkjavascript.org/dom/docs >
--
Rob
"RobG" <rg***@iinet.net.auwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>It hasn't anything to do with rails or ajax though, for that you will use the rails helper scriptaculous.
Not Scriptaculous, Prototype.js's addClassName and removeClassName
methods:
$(id).addClassName('blah');
However, other frameworks can be used with Rails, e.g. Fork's addClass
and removeClass:
<URL: http://www.forkjavascript.org/dom/docs >
jQuery has a similar method.
$('p[@id=p1]').addClass('className');
Will take a P tag with an attribute ID of p1 and add the class named className.
$('p.className').addClass('className2');
Which takes a P tag, with a class of className, and adds className2, to it.
Not knocking Michaux either!
-Lost
On Mar 14, 12:25 pm, "-Lost" <missed-s...@comcast.netwrote:
"RobG" <r...@iinet.net.auwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
It hasn't anything to do with rails or ajax though, for that you will
use the rails helper scriptaculous.
Not Scriptaculous, Prototype.js's addClassName and removeClassName
methods:
$(id).addClassName('blah');
However, other frameworks can be used with Rails, e.g. Fork's addClass
and removeClass:
<URL:http://www.forkjavascript.org/dom/docs>
jQuery has a similar method.
$('p[@id=p1]').addClass('className');
Will take a P tag with an attribute ID of p1 and add the class named className.
$('p.className').addClass('className2');
Which takes a P tag, with a class of className, and adds className2, to it.
Can jQuery be used with Rails a la Prototype.js?
--
Rob
On 14 mar, 03:47, "RobG" <r...@iinet.net.auwrote:
On Mar 14, 12:25 pm, "-Lost" <missed-s...@comcast.netwrote:
"RobG" <r...@iinet.net.auwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>It hasn't anything to do with rails or ajax though, for that you will
>use the rails helper scriptaculous.
Not Scriptaculous, Prototype.js's addClassName and removeClassName
methods:
$(id).addClassName('blah');
However, other frameworks can be used with Rails, e.g. Fork's addClass
and removeClass:
<URL:http://www.forkjavascript.org/dom/docs>
jQuery has a similar method.
$('p[@id=p1]').addClass('className');
Will take a P tag with an attribute ID of p1 and add the class named className.
$('p.className').addClass('className2');
Which takes a P tag, with a class of className, and adds className2, to it.
Can jQuery be used with Rails a la Prototype.js?
--
Rob
Thanks to all for your answers. It is really helpfull!
RobG, even if prototype and scriptaculous are in the default package
you can use other ajax library instead of this one. But i've never
done it. Maybe you should read this post : http://yehudakatz.com/2007/01/31/usi...-rails-part-i/
and thanx again.
"RobG" <rg***@iinet.net.auwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
On Mar 14, 12:25 pm, "-Lost" <missed-s...@comcast.netwrote:
>"RobG" <r...@iinet.net.auwrote in message
news:11**********************@n59g2000hsh.googleg roups.com...
>It hasn't anything to do with rails or ajax though, for that you will use the rails helper scriptaculous.
Not Scriptaculous, Prototype.js's addClassName and removeClassName
methods:
$(id).addClassName('blah');
However, other frameworks can be used with Rails, e.g. Fork's addClass
and removeClass:
<URL:http://www.forkjavascript.org/dom/docs>
jQuery has a similar method.
$('p[@id=p1]').addClass('className');
Will take a P tag with an attribute ID of p1 and add the class named className.
$('p.className').addClass('className2');
Which takes a P tag, with a class of className, and adds className2, to it.
Can jQuery be used with Rails a la Prototype.js?
Yes, I believe so. http://docs.jquery.com/Core#.24.noConflict.28.29
Illustrates jQuery playing nicely with other such libraries, namely Prototype.
Also, JQuails looks promising. Did not find too much information on it though, so cannot
be sure.
-Lost This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: revolnip |
last post by:
As attached is the code :
<% Option Explicit
dim lngTimer
lngTimer = Timer
%>
<!--#include file="Connect.asp" -->
<!--#include file="Settings.asp" -->
<!--#include file="Common.asp" -->
|
by: grahamo |
last post by:
This came up in an interview I did a while ago and I wanted to know
the correct answer. The setup is this;
If I have a base class "food" and also two classes "meat" and "veg"
that inherit from...
|
by: chrisspen |
last post by:
Is there a way to loop through all instantiated objects and update
their classes when a source file changes? I know about Michael Hudson's
method...
|
by: Kha Tran |
last post by:
When using function update of objectdatasource, I can call a function with
parameters like id, name... (properties of object). Can I pass a parameter
as an full object?
Ex: update(id, name,...
|
by: Matheas Manssen |
last post by:
Hi,
When run the following class with midp 2.0, the midlet hangs. I think it
happens in the flushGraphics() method. Does anybody know the solution?
Best regards,
Matheas Manssen
import...
|
by: Brett Romero |
last post by:
Say I have a class inheriting some base class:
BaseClass
{
void Foo()
{
Update();
}
}
|
by: Ivan |
last post by:
I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and...
|
by: Andy Terrel |
last post by:
Okay does anyone know how to decorate class member functions?
The following code gives me an error:
Traceback (most recent call last):
File "decorators2.py", line 33, in <module>
s.update()...
|
by: TamusJRoyce |
last post by:
Hello. This is my first thread here.
My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic).
My problem is that I...
|
by: semanticnotion |
last post by:
I have a page that lists records from a database call. I want to have an 'edit' link on each row that will popup a Jquery dialog so that the row can be edited. My question is how do I pass the data...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shćllîpôpď 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |