javascript

how to organize javascripts using rails and jquery

Hi, i'm working in a big and rich rails web application using tons of javascript. I would like to know if anybody has a tip to organize the javascripts. Today i'm generating a new file named controller.js and adding it to my views using content_for. The problem is, some files are becoming big and sometimes, i need a function from one co...

Prototype.js shortcut for getting value of an element ?

I didn't use Prototype.js before, when I use jquery, I can get an element value like $("#inputA").val(); Is there an equivalent method in prototype like this? I use $("inputA").getAttribute('value');, which is very verbose. ...

How to append a row to a TableViewSection in Titanium?

I'm developing an iPhone application in Titanium, and need to append a row to a particular TableViewSection. I can't do this on page load, as it's done dynamically by the user throughout the lifecycle of the application. The documentation says that the TableViewSection has an add method which takes two arguments, but I can't make it wo...

Regular expression to match a name

What will be the regular expression in javascript to match a name field, which allows only letters, apostrophes and hyphons? so that jhon's avat-ar or Josh is valid? Thanks ...

How to be a jQuery no.conflict expert?

How to be a jQuery no.conflict expert? I mostly face jQuery conflict errors with Prototypes JS. and I'm nota jquery expert. Can I still solve all conflict problems. how to get expertize to solve conflict issues. How to know whole code is jquery. what if simple javascript and jquery code mixed in one js file? What if inside external j...

Google Ajax Search results differ from "normal" Google Results ?

Hi Folks, I guess anything important you might have to know is within the title. If I use the Google Ajax WebSearch API with, for instance, "Dummy Search" as phrase, my resultset is a different one than if I perform the same phrase over google.com. How can that be? My querystring paramter options are exactly the same, language etc. T...

Ruby on Rails - Send JavaScript to view

Hey, I am creating a website in Ruby on Rails. I have a controller action that renders a view like so: def show time_left = Time.now.to_i - 3.hours.to_i @character = current_user.characters.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @character } end end This is f...

Access SVG inside HTML

Hello, I use SVG inisde my xhtml file. I can not get access to the text with id="Wert". What is wrong, I want to change the color form blue to red. Untitled Page <script type="text/javascript"> function OnLoad() { setTimeout("timer()", 1000); } function timer() { var randomnumber = Math.floor(M...

jQuery $.ajax Not Working in IE8 but it works on FireFox & Chrome

I have the following ajax call which works perfectly in Firefox and Chrome but not IE: function getAJAXdates( startDate, numberOfNights, opts ) { var month = startDate.getMonth() + 1; var day = startDate.getDate(); var year = startDate.getFullYear(); var d = new Date(); var randNum = Math.f...

Exceptions thrown in jQuery AJAX callbacks swallowed?

Is there any way to handle exceptions thrown from AJAX callbacks in jQuery, other than adding a try..catch block to each callback? The error function is not called in this situation. $.ajax( { url: 'myurl.rails', success: function( data ) { throw 'Oh no!'; }, error: function ( xhr, textStatus, errorThrown ) ...

How does one get access to the Flash object's vars in IE?

Is there a way in IE Browsers to access the Flash object? In this case it is made with mootools swiff. It´s working fine in all other browsers, because they can wrap this object correctly. But it does not work in IE. Here is the script: var swfObj = $('mbImage').getElement('object'); swfObj.get('data'); <--- Thats not working in IE ...

SEO friendly javascript and CSS links?

Is it possible to have a navigation system optimized using javascript, but for the sake of search engines, have the hyperlinks still be crawlable? Or maybe a condition statement that calls HTML code only if javascript is not enabled in the browser or when crawled by a search engine? ...

Javascript: How to filter object array based on attributes?

I have the following JavaScript JSON array of real estate home objects: var json = { 'homes' : [ { "home_id":"1", "price":"925", "sqft":"1100", "num_of_beds":"2", "num_of_baths":"2.0", }, { "home_id":"2", "price":"1425", "sqft":"1900", "num_of_beds":"4"...

Javascript double click text transform into textbox

Hi to all! What is the javascipt code that will edit a text on double click. The process is I have a text and if I double click it, a text box will appear, and if I press enter the word will change depends on what you've type. Sample This is sample text. $nbsp;$nbsp; --> if I double click it a textbox will appear. <input type="text" va...

Javscript passing and using that function

I have: var f1 = function(a){ alert(a) } var f2 = function(data, method){ method(data) // the problem is here, // the method f1 is not called. Is there a way to call that method f1? // the method f1 might not be in this scope, the method f1 can // be in a class or like this... } f2(a, f1) The question is: Is t...

Accessing contents of NativeWindow in a HTML AIR application?

I'm currently building a HTML/JS AIR application. The application needs to display to the user a different 'window' - dependant on whether this is the first time they've launched the application or not. This part is actually fine and I have the code below to do that: if(!startUp()) { // this simply returns a boolean from a local prefere...

Javascript add a PHP file.

var editing = false; if (document.getElementById var buttext = document.createTextNode('Ready!'); butt.appendChild(buttext); butt.onclick = saveEdit; } function catchIt(e) { if (editing) return; if (!document.getElementById || !document.createElement) return; if (!e) var obj = window.event.srcElement; els...

Adding new input row to form on event click

http://stackoverflow.com/questions/1564566/using-jquery-to-add-or-remove-form-elements/ when i click the add link the information in the existing input field disappears. How do i tell it to retain this information. ...

Open Flash Chart 2 not understanding "steps" in Internet Explorer

Hi I have a problem with Open Flash Chart 2. It works like it should in FireFox, but in Internet Explorer my Y axis is all wrong. No matter if I set the "steps" or not, it is not accepted in IE. Then it just takes my "max" and creates 5 steps with some weird numbers like 11.6, 23.2, 34.8, 46.4 and 58. Why? My JSON that I pass to OFC2 l...

How to get the dimensions of the scroll bars ?

I have an HTML table that contains lots of rows and columns. Therefore, it has vertical and horizontal scroll bars. How can I get the dimensions in pixels of these scroll bars in Javascript/jQuerys ? ...