I have two objects: oldObj and newObj. The data in oldObj was used to populate a form and newObj is the result of the user changing data in this form and submitting it. Both objects are deep, ie. they have properties that are objects or arrays of objects etc – they can be n levels deep, thus the diff al…
Tag: javascript
Javascript Named Function Expressions in Internet Explorer
Why does the following code not work in Internet Explorer (I’ve only tested in IE8 so far): If I change foo’s assignment to the following, the code works just fine: I imagine it’s something to do with named functions in IE’s Javascript engine. The code works fine in Chrome and Firefox.…
How to start and stop/pause setInterval?
I’m trying to pause and then play a setInterval loop. After I have stopped the loop, the “start” button in my attempt doesn’t seem to work : Is there a working way to do this? Answer The reason you’re seeing this specific problem: JSFiddle wraps your code in a function, so start(…
Facebook Like button causing horizontal scrolling on mobile device
I have a Facebook Like button implementation which is rendering fine in all browsers desktop and mobile. But the issues lies on low-res devices with resolution of 240×320. the Like button is causing the device to zoom into the page thus rendering horizontal scrolling. The buttons is rendering fine on dev…
Make a number a percentage
What’s the best way to strip the “0.”XXX% off a number and make it a percentage? What happens if the number happens to be an int? Answer A percentage is just: No need for anything fancy:
JS search in object values
I have an array of homogeneous objects like so; I’d like to search these objects’ values (not keys) with a keyword, and return an array of objects that contain the keyword in any of the values. So for example, with a keyword r, I would get all the objects (“baR” in object #1, “lo…
Javascript sort not working in Firefox
I have the following code which is sorting a list of javascript objects in an array based on their date. The data is coming from an XML file. The date is formatted as follows: MM-DD-YYYY So at this stage I have a load of concert objects in my concerts array. I then go to sort it and output it to
Insert content at top of page without scrolling
Is there a way that I can insert content at the beginning of a webpage without causing the page to give the impression of scrolling up. I’m trying to implement something kind of like infinite scrolling but I need to be able to scroll up infinitely as well as down (I’m also unloading content on the…
trouble with recursion; parsing JSON
I have a json object like this: …and I’m trying to iterate through it and get a total count on the “text” objects. I can’t seem to be able to get something recursive working.. I think I’m missing a base-level understanding of both json and recursion.. After a couple of days…
JQueryUI resizestop event not bubbling with helper
I am using Backbone View events to listen for JQueryUI’s resizestop. This worked with JQuery 1.6.4, but not with 1.7.1. It seems to only be an issue with the resize helper on. This is a super-specific bug, so the question is how does one debug such things? edit Simplified test, without Backbone: http://…