javascript

How do I add a function to a specific element type in jQuery?

I can do this jQuery.fn.validate = function(options) { var defaults = { validateOPtions1 : '', validateOPtions2 : '' }; var settings = $.extend({}, defaults, options); return this.each(function() { // you validation code goes here }); }; but that will make validate() available for every el...

I want to input JSONObject from jquery.post() to a a simple JS chart(bar chart)?

HI I am very new to both json and js charts. In the example of bar chart, they are giving a hard coded array like this, var myData = new Array(['U.S.A.', 69.5], ['Canada', 2.8], ['Japan & SE.Asia', 5.6] ); var myChart = new JSChart('graph', 'bar'); myChart.setDataArray(myData); Instead of that I want to use the response of $.post() m...

Formatting Controls in ASP.NET

I feel as though this this is a simple question, but can't find an answer anywhere. We've got an interface we're trying to move to an ASP.NET control. It currently looks like: <link rel=""stylesheet"" type=""text/css"" href=""/Layout/CaptchaLayout.css"" /> <script type=""text/javascript"" src=""../../Scripts/vcaptcha_control.js""></sc...

How to reference an anonymous JavaScript function?

I'm trying to call a Page Method using a jQuery 'attached' event function, in which I like to use the closure to keep the event target local, as below, but page method calls declare several 'error' functions, and I would like to use one function for all of them. If, in the below code, I was handling an error and not success, how could I...

How can I preview the file in a file input using JavaScript?

I want to be able to preview an image for a user before they upload it. I've of course discovered that all the modern browsers obscure the actual full path in one way or another, so my original plan of just setting an <img /> element with the local path is out of the question. I've found this solution, which isn't bad, but I'm expectin...

Is it possible to make a Firebug console automation?

I want to automate actions in firebug JavaScript console. ie. Is it possible to load a page from url in firefox then after the page is loaded run a js code in console? I have googled for solutions and found one:Running_Automated_Test_Suite with FBTest is there any other ways to do that? Which one is easier? Some ways w/ windows cmd-lin...

Javascript Array.forEach HowTo break?

[1,2,3].forEach(function(el) { if(el === 1) break; }); How can I do this using the new forEach method of JS? ...

Loading html dynamically using Javascript and PHP

I have the following code: <?php if ($x == 1){ ?> <b>Some html...</b> <?php } else if ($x==2){ ?> <b> Other html...</b> <?php } ?> Now I would like to have two links below (a href) and somehow pass the variable $x (so Link1 passes x=1 and Link2 passes x=2) in order to load the relevant bit of code from if...

JS zooming framework (google maps style)

I'd like to build a web app based on a zooming principle (ZUI) I'm looking for a framework or a starting point. something like OpenZoom http://openzoom.org/ but in javascript Thanks ...

Javascript: find URLs in a document

how do I find URLs (i.e. www.domain.com) within a document, and put those within anchors: < a href="www.domain.com" >www.domain.com< /a > html: Hey dude, check out this link www.google.com and www.yahoo.com! javascript: (function(){var text = document.body.innerHTML;/*do replace regex => text*/})(); output: Hey dude, check out th...

Can I select input nodes based on value in JQuery?

I have a list of file input boxes and I want to know if any of them have a value using a single selector statement. Can I do something like this: $('input:file[value!=null]') or something similar. ...

Return variable in function from method callback data in same function

How do I return the latlon variable for codeAddress function. return latlon doesn't work, probably because of scope but I am unsure how to make it work. function codeAddress(addr) { if (geocoder) { geocoder.geocode({ 'address': addr}, function(results, status) { if (status == google.maps.Geocoder...

What is a good way to ensure the background of a flash object matches the page?

Since there is no way that you can make the flash object transparent, there needs to be some other means by which you can match the background. I thought of maybe creating a ActionScript/Javascript bridge, but I wonder if this is the route to take. Do I have a better option? ...

jQuery / jEditable and jQuery UI Dialog. Re-populating table cell.

Hello, this is my first time using JS, so i really have no idea what i am doing. I have a table with data, and using jEditable to allow a user to edit the data and POST it to my php script. When user hits "Save", it opens jQuery UI with the data from php script and it seems to work fine, however, if the user hits Cancel or Esc to close ...

Build a JavaScript wrapper for a rails-generated XML API?

I am working with a large website written in Ruby on Rails. Thanks to the support for REST in Rails 2, the site's business logic is all accessible via a consistent XML API. Now I want to be able to easily write one or more JavaScript frontends to the site that interact with the generated Rails XML API. Ideally, an automated wrapper for ...

Using Ext.Panel how do I specify a .php page as the html source?

I have an existing panel where I set the html manually with a variable like so: s = '<H1>My Html Page'; s += '[more html]]'; var panel = new Ext.Panel({ id: 'service_Billing', title: 'Billing', tbar: [], html: s }); How can I specify a path on same server server of a .php file ...

Ubiquity CmdUtils.setSelection won't replace HTML

I'm attempting to write a Ubiquity command that allows you to replace a selected link or URL pointing to an image with that image itself. However, the CmdUtils.setSelection() function (documented here) seems to do nothing if any html tags are present in the selection, making it useless for replacing any links. When selecting plain text, ...

Text Hints with JQuery and JavaScript for loop

Hey guys! I'm developing a small app where i ask users to put some info. I want to show text hints in the input fields. I do this in a for loop... When the page is loaded, the hints are displayed correctly but nothing happens on 'focus' and 'blur' events... I'm wondering why since when I don't use a 'for loop' in my js code, everything...

Access event.target in IE8 unobstrusive Javascript

The following function gets the target element in a dropdown menu: function getTarget(evt){ var targetElement = null; //if it is a standard browser if (typeof evt.target != 'undefined'){ targetElement = evt.target; } //otherwise it is IE then adapt syntax else{ targetElement = evt.srcElement; } //return id of <li> elemen...

How can I make a list self-arrange in an animated way based on periodic json updates ?

I have a list of complex entities (divs), that are scored. The list will be sorted based on updates from the server as the user fills out a form. What i haven't figured out is how to animate the entities into their new positions. I don't want to just refresh the list. Is there a magic JQuery technique that achieves this? ...