javascript

Allowing javascript function to accept any number of arguments

I would like the below function to be more flexible and accept multiple callbacks to other functions if they are defined in the arguments. $(function() { function icisDashBox(colorElem, thisWidth, thisHeight, completeCallBack) { $(colorElem).colorbox({ transition: 'none', ...

jQuery Horizontal Accordion Space To Far Right Whilst Animating

Hi, I've created a horizontal accordion in jQuery, starting here as a base: http://www.webdesign.org/html-and-css/tutorials/jquery-examples-horizontal-accordion.15528.html When it animates, a small amount of space is added to the far right which causes the tabs on the right hand side to move a bit. It doesn't look very good. It's all ...

Access asp:HiddenField through javascript from target page in anchor tag

Hi, I have a page (startPage.aspx) which transfers control to another page using an anchor tag i.e. (a href="newPage.aspx"). I would like to know how I can access some form element on startPage.aspx from the newPage.aspx in javascript? (eg: document.getElementById, etc). The element I am trying to access is an asp:HiddenField which does...

Server polling with JavaScript

What is best practise for polling server with JavaScript for application that needs to refresh data very rapidly? I'm using jQuery for front-end and Java Spring Framework for backend. Example of refreshed data could be list of items that are getting updated very rapidly (every 1 second). ...

Jquery - Sort div by class using data()

Hi, is it possible to sort div by using the data function? html <div id="gp_21" class="line">one</div> <div id="gp_35" class="line">two</div> <div id="gp_11" class="line">three</div> <div id="gp_29" class="line">four</div> <hr /> <div id="check"></div> js $(document).ready(function rt() { $('#gp_21').data("rtt", { age: '25135...

How to move the cursor into a input text box by clicking a label tag?

Hi All, How to move the cursor position into a input text box by clicking a label tag? Much appreciated ...

Hoverintent for Prototype / Scriptaculous

Recently came across the HoverIntent plugin for jQuery. It acts like a regular mouseover or hover observer, but waits to fire the action until/if the mouse slows down or rests. With tuning, it makes for interfaces that feel more human responsive. The website I'd like to use it on is committed to a Prototype / Scriptaculous framework...

IE 7 CSS Issues

Okay, I'll be the first to admit that i'm quite terrible when it comes to css, but I try... :D I have this JS Function which I use to create rounded corners using images, instead of the standard div in div in div way. I know there are better ways, but this is how i've done it: function applyHorizontalImageCornersSpecific(div, left, midd...

jQuery-UI Opacity Effect on Tabs

I'm having some issues using the opacity effect on jQuery-UI tabs... especially in IE Here is my code; $('#featured').tabs({ fx:{ opacity: "toggle" } }).tabs('rotate', 5000, true); Check out http://www.jsfiddle.net/cxNj8/4/ Apart from the effect...

Refresh <div> element generated by a django template

How do I refresh a certain element within a django template? Example: {% if object.some_m2m_field.all %} <h3>The stuff I want to refresh is below</h3> <div id="the-div-that-should-be-refreshed"> {% for other_object in object.some_m2m_field.all %} <a href="www.example.com">{{ other_object.title }}</a> &nbsp; ...

Global Date Handler for javascript

Hi, I have a site that uses JavaScript extensively. But my problem is now that my site is being used by various timezones the date and times are incorrect when displaying data from the server (TZ A) and Displayed on the client using JavaScript (TZ B). My site is ASP.net if that makes any difference. Originally I never catered for UTC ...

Reverse-engineering a Dashboard Widget?

Is it possible? I understand that Dashboard widgets are simply Javascript packaged up nicely, but is it possible to view the source of that Javascript? I realise this might be a silly question, but before I create a Dashboard widget for my site accessing an API URL I don't want to be public yet, I'd just like to check. And yes, I know...

Jquery UI draggable: clone if Ctrl pressed down

I have a list of draggable table cells that can be dropped onto a second table. They are set to clone, as the original table should remain unchanged if items are dragged from it. Now I want to be able to move the dropped elements inside the second table from cell to cell. But if the Control key is pressed while dragging an element insid...

How can we get randomly selected text and image in javascripton on mouseup from page?

I want to get selected text and image on mouse event .Since there is an randomly changed text and image on my page.I have getting the only selected text not image.So please tell me how can I get the selected image in JavaScript ? I used window.getSelection() but this will return only selected text not images ..so please guide me to solve...

Javacript hide additional text field in existing script

I am using this code: http://jsfiddle.net/q3nUS/ $('#cf11_field_20').change(function() { $("#li-11-22")[$(this).val() == "full03_accommodation_hotel" ? 'show' : 'hide']("fast"); }).change(); $('#cf11_field_22').change(function() { $("#li-11-23")[$(this).val() == "full03_hotel_other" ? 'show' : 'hide']("fast"); }).change(); It wor...

How do I add a delay in a JavaScript loop?

I would like to add a delay/sleep inside a while loop: I tried it like this: alert('hi'); for (var start = 1; start < 10; start++) setTimeout(function () { alert('hello'); }, 3000); Only the first scenario is true: after showing alert('hi'), it will be waiting for 3 seconds then alert('hello') will be displayed but then alert('...

How often can I have ajax ask for new data?

I am working on designing a collaborative system where multiple users can edit the same document, much like googledocs, and I guess 'search suggestions', but in no way as advanced. My question is this, will my design work? I know enough php/ajax to design this, using jQuery for the ajax part. But I have never made such a system, and the...

Passing numerically indexed PHP array to javascript

I've got a PHP array in this format: $js_data_array[] = array('href' =>$matches[1][0], //this is an image url 'title' =>'Lorem ipsum dolor sit amet, consectetur adipiscing elit', ); And I need to get it into this format in javascript [{ 'href' : 'http://farm5.s...

How to pan a map to a floatPane overlay in Google Maps API V3?

I have a class based on google.maps.OverlayView which implements a custom replacement for a standard InfoWindow. You can see my custom overlays in action at http://www.qype.co.uk/uki/explore/category/883-eating-and-drinking I need to be able to pan a map when the overlay doesn't fit completely in the visible area (standard behaviour f...

Avoiding multiple instances of the same JS file.

I've found that loading the same javascript file twice or more (via PHP) can cause errors in IE (such as: line 1 char 1 code 0). This occurs when a webpage is constructed from nested templates - in this case, CakePHP. Is there a way to include a file only once? Perhaps, in CakePHP, it can be done by manipulating the $scripts_for_layou...