Posts Tagged javascript

“Changing the class of a div using rails NOT JS”

Consider we need to change the class of a particular DIV/SPAN , I was wondering how we could have done using some default rails method and NOT Javascript as what we can do in Javascript the same we can do using Rails but in lesser time and number of lines of code.
Using google with the correct key words resulted in the following

Javascript

function change(id, newclass)
{
identity=document.getElementById(id);
identity.className=newclass;
}

Rails

page["task_#{params[:id]}”].toggle_class_name “completed”

, , ,

Add comment December 9, 2008

“Javascript made me feel like a IDIOT”

Today I was doing some javascript checks so that my regular price remains
always greater than the discounted price .

I check with normal arithmetic functions “==,<,>” to the $(“field_name”).value
and thought it has worked because that what was taught to me in my schools
that value 1 > value 2 returns true/false.

But all my prettiest school teachers were proven wrong by javascript.

I realized after releasing the code that
11> 10 => true
99.99 > 99.98 => true
212 > 212.21 => false

but they were also checking the number of digits.
So when I gave

10 > 9 => false
(It failed) …hmm even I had the same reaction!!!!

Man , what the S**T cum on how can this happen , then I thought
bro need to check javascripts arithmetic handlers once again ,
over there I came accross parseFloat and other functions.

check the link for more details

For the next two days I shall be wearing the “I was wrong ” Tshirt….

Technorati Tags: , , , , , , , , , , , ,

1 comment July 2, 2008

“Run Ruby on a JavaScript interpreter?”

&amp;lt;script type="text/ruby"&amp;gt;class Pi  def initialize 	@a = 355.0  end  def calc	b = 113.0	return @a / b  endPI = 'PI is about'	endputs Pi::PI

puts Pi.new.calc &amp;lt;/script&amp;gt;

&amp;lt;body onload="Print(); new function().runFromScriptTag('/compileRuby.cgi')"&amp;gt;

Add comment April 17, 2008


Recent Posts

Tags

Active Record australian gp calendar date select capistrano capitalize debugging Debugging in rails edge rails formula 1 For those who dont want to update the prototype.js fun Fun baby fun google html in join javascript linus vs windows compatibility linux logging love song malaysian gp 2008 results melbourne migrations music mysql plugin poetry rails regexp regular expression results formula 1 opening race romantic poetry ror Ruby ruby on rails safe html sms song SQL string case handler for strings syantax syntax error for migrations on linux Text Area they can checkout 1.8.3 of the calender date select

Blogroll

Pages