javascript

Unable to append content coming back in JSON

I have the following JSON coming back: {"gameId":137.0,"memberId":3,"id":97.0,"reviewBody":"Great game! Awesome.","createdAt":"October, 13 2010 18:55:34"} I'm trying to append it to a layer using the following JavaScript, but nothing is showing: $(function(){ $(".review-form").submit(function(){ dataString = $(".review-fo...

Extjs : How to combine Tab Panel and Menu panel in one Panel just like in Internet Explorer

I have requirement that I need to combine Tabs and menus in one panel just like IE. Is this possible? ...

better understanding of callback functions in javascript

I am reading this function in a book, and I don't understand how the anonymous function is passed the thirst three arguments? This is what I understand function multiplyByTwo(a, b, c, callback) { var i, ar = []; for(i = 0; i < 3; i++) { ar[i] = callback(arguments[i] * 2); } return ar; } but not this myarr = multiplyByTw...

Copy javascript object with private member

Hi, I've looked all around and found nothing to help me. Why on earth can't I clone a javascript object with private members without making them quantum entangled? Just look at this code... It's a plain private property with getter and setter. Somehow if I call the public setter on one instance, the cloned one gets changed too. Why? Ca...

jQuery call for a partial doesn't work if there is RoR code in it?

Hi, I am trying to get paginating to work with jQeury. I am using the will_paginate gem. It works normally (with no javascript). I tried following a railscast (http://railscasts.com/episodes/174-pagination-with-ajax) but I am still having a problem. show.js.erb $('#comments').html("<%= escape_javascript(render "comments/comment.html.e...

how to handle iPhone popups automatically without any user interaction?

I'm working on a tool that helps to automate Browser based products. On of the use case I encountered is to handle popups either from application or from Safari. I would like to provide an API where a user can click OK when a popup prompts. Can I do it through JS or is it possible through any Apple API? And one more thing, how do I know ...

problem with proprietary style names in FireFox when modifying styles through document.styleSheets

I am experimenting with changing some stylesheets from javascript I have come across a strange issue: When I set an attribute on a style rule it silently fails in Firefox if the property is one of their proprietary ones. I have made an example demonstrating the issue (live example): <html> <head> <style type="text/css"> div { margi...

correct way of hiding HTML content

Hi all, I am writing a small HTML+JavaScript (so to call) application. User is given two choices (radio buttons) and depending what did he choose, I display content "A" or content "B" under the choice radio buttons. Now I am wondering what is a right way to handle this content. Should I have 2 DIVs, only one visible, depending on choic...

Loading a form with input text rows equal to a passed variable number using the clone function

All I want to do (and it would be easy enough with PHP, but I'm pushing myself to learn more javascript and jQuery and front end coding right now by modifying scripts to understand what they do) is to build a form with the same number of rows as the "Seats" variable stipulates from a previous form. Then the registrant can enter the name...

emit ampersand to html page in javascript

I want to emit an '&' without the '&amp;' on the page document.write('&'); emits &amp; document.write('\&'); emits &amp; Proof in the generated html <html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt; <title></title> </head><body> <script type="text/javascript"> document.write('&'); document.write('\&'); </s...

jquery waiting for $.each to finish

Hi I have a huge problem that's been bugging me for quite a while, most of the times I have been able to avoid it but now there is no other way. Below is a function that when executed sends a post request for every checked boxes. I need it to wait until the $.each has finished to refresh the page. I have performed tests with location.rel...

JSF complex cascading radio buttons

I need to port an application from PHP to JSF 2. Everything is fine except for a rather complex radio button group: When 'Process Application for:' is selected, the child radio button group is enabled. Within that, when 'Other' is selected, the corresponding text box is enabled. When 'Brands' is selected, those two text boxes are en...

jQuery scrollLeft not working

I just launched http://elliewauters.com & have a little problem that I'd like to fix, the site uses a lot of animated horizontal scrolling to go from one 'page' to the next, but on refresh most browsers remember the scroll position & go back to where I was before, I do not want this. Try going to the 'About' page & then refreshing. You'l...

Unknown issue (AJAX / GET)

Alright so pretty basic, here are the pieces of code I have, basically it's supposed to updated my table "comments" on the "like" column. My problem is situated in the javascript while trying to submit the result. SPAN which contains a link to submit: <span id="like<?=$i?>"><a href="javascript:void()" onClick="likeComment(<?=$row[comme...

Using JavaScript and XHTML: XMLHttpRequest's open/send do not work if before onreadystatechange.

I don't know if it "works" or not, but I am concluding this because the code posted here, works (except for what's in the for loop (stupid DOM), but that's not the focus) ONLY after two clicks. I'm assuming this is because it is not getting the XML document till it's created, which is at the end of the first click. However, if I were to...

With a 3rd party Open X Server, how can we stop it from attempting to load if their site goes down?

The code below is the ad that is being served. Since the ad is at the very top of the page, we want to make sure that it doesn't stop the site from loading if their server happens to go down. We are looking for either a javascript or C# ASP.NET solution. We have tried rewriting it to work on DOM Ready, but it does not seem to work tha...

jquery/javascript - parsing url to see if you're on a certain page

So say you have some navigation, and you don't/can't use server side code to choose which link is "current". How can you use the first part of the url (as in after the first slash but before any next slash) i.e. (example.com/dashboard/view/16) would return dashboard. Of course there's not always a second slash, it could be (example.com/d...

truncate text based on div size

i have a long MULTILINE text inside a div box and I want to truncate it and put an ellipsis in the end. I thought of truncating it based on characters but when I switched browser (from chrome to firefox), firefox renders the text thicker. :( Can you help me with this? ...

Get browser window position regardless of zoom

How can I get the browser window's left edge (including menu, border, caption, etc), without it being "fixed" to take into account the zoom level? (This question addresses the basic question, but does not consider zoom.). window.screenLeft or window.screenX work fine on Chrome and Safari, but these report "fixed" values using IE6, IE8 ...

JS if inside for loop

I'm trying to rewrite this as a for loop; my attempt below failed. Any ideas? jQuery.event.add(window, "load", resizeFrame); jQuery.event.add(window, "resize", resizeFrame); function resizeFrame() if ($(window).width() < 232){ $("#grid-content").css( 'width', '232px' ); }else if ($(window).width() < 458){ $("#gri...