javascript

ANT. Override properties. Optional Execution in Single Target

I'm going to post a question that I've seen variants of elsewhere, but where I've not quite seen the answer I came up with. I'll subsequently post my answer. In order to modularize my build script using macros, I would like to put both the updatetask and the task I want to execute if it is not up to date, in the same macro. How do I do...

How to update an input text from javascript?

Hey guys, I have this simple code that speaks for itself.Here it is: enter code here <script language='javascript"> function check() {} </script> <div id="a">input type="text" name="b"> <input type="button" onClick=" check(); "> All i want is that when i press the button, the text field gets a value updated to it. i tried us...

Does something like jQuery.toggle(boolean) exist?

I write something similar to the following code a lot. It basically toggles an element based on some condition. In the following made-up example, the condition is "If the agree checkbox is checked and the name field isn't empty". $("button").click(function() { if ($("#agree").is(":checked") && $("#name").val() != "" ) { $("#mydiv...

Netbeans JQuery Selector auto-complete

I can't get Netbeans to auto-complete my selectors for JQuery, example: <a id="hello" href="#">Hello</a> <script type="text/javascript"> $("|").hide(); </script> As far as i understand the documentation at this point it should show the tags available on the page when i press control+space at the | position, but instead displays no...

Javascript regex: How to extract an "id" from a string?

I have this string: comment_1234 I want to extract the 1234 from the string. How can I do that? Update: I can't get any of your answers to work...Is there a problem with my code? The alert never gets called: var nameValue = dojo.query('#Comments .Comment:last-child > a[name]').attr('name'); alert('name value: ' + nameValue); // comme...

jQuery fade in ajax loaded div isn't smooth.

When running the following locally, the fade in is very smooth, but on a remote server the content loaded into the target div appears, is instantly hidden, and then fades back in again. Why does this happen and how do I fix it? My jQuery (inside the document.ready stuff) looks like this: $(".dataclick").click(function() { $('.clic...

How to find where prototype is being used?

We have 600 jsp files and I need to find out where we are using prototype. Is searching for "$(" the best way to do this? Will it catch all instances of searching for where prototype is being used? (If not, please provide what you would search for) ...

When I include only the jQuery 1.4 Library, I get an exception, why?

I keep getting this error all over the place where I only have jquery 1.3 or 1.4 included. "setting a property that has only a getter" and a long list of warnings in the Firefox Error Console. What's going on? I can't find any information on this issue =/ <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/...

Minimalist, Tiny Javascript Template System?

I'm looking for a minimalist template system for javascript, ala John Resig's Javascript Micro Templating. The smaller the better, and if it's jquery based even better. Recommendations? I tried John's micro-templating but ran into a few issues, wanted to see if there are more baked / better packaged solutions out there. [Update] I trie...

Adding charts dynamically with flot

I'm running the following code. The button basically adds a chart into the html page. The problem I'm facing is: when I click on the button for the second time, the curve of the former chart fades away (though the labels don't), and I want it to stay. I've tried to debug and this happens when I modify the innerHTML property right at the ...

Disable back button in GWT

Is there a way to disable the Back button in a browser (basically clearing the History token stack) in GWT? Once I browse to a certain page in my application I want to make sure that the user can't use the back button to go back, but only be able to use links on the page to navigate the site. ...

Can someone explain last year's reddit exploit to me?

Last year a user managed to inject arbitrary javascript into reddit's markdown syntax. Can someone explain how this was done and how I can test whether my site is similarly vulnerable? ...

JQuery Positioning Problem

Hello, I have been trying to create a menu panel with JQuery that can be seen here by clicking the Preview button on top: http://jsbin.com/amexi/edit Problem: If you hover over Link Two or Link Three, the black panel comes perfectly replacing the respective blue link, however if you hover the Link One, the black panel comes little be...

Removing READONLY attribute from textbox using client side code

I have a multiline textbox that by default, is set to ReadOnly. I would like a button on the page to change the control to allow it to be edited. I would like this code to run on the client side because the page renders slowly and I'd like to avoid the post back. The problem I'm having is the javascript code that I wrote to remove the ...

Before every ajax request using jQuery, I want to do sth.

means, do sth, then request using jQuery, like a hooker. How can i do this? ...

Resource for Refactoring tips geared towards JavaScript

Hi all, I'd like to start a discussion on the best resources for refactoring tips, with an eye towards Front-End JavaScript refactoring. A friend whose opinion I respect suggests this book, though it uses examples in Java. I understand that the principles of OO refactoring should translate to another language. Let's talk about refactor...

A function of a slider value suitable for zooming

I'm using the jquery ui slider for zooming. It's supposed to zoom from 25% to %500, and about half of the range is used for the first %100 of the size. The slider has values from 1 to 100. I need some function that can be used to calculate zooming based on the slider value, e.g. function getZoom(sliderVal) { //return number from 25...

Javascript's object.onClick runs the function instead of setting onClick, how can I prevent that from happening and only execute the function onClick?

I have the following code: function sdefaults() { alert("test"); } var btnpos, sbtn; btnpos = document.getElementsByName('somePosition')[0]; sbtn = document.createElement('input'); btnpos.parentNode.insertBefore(sbtn, btnpos.nextSibling); sbtn.type = "button"; sbtn.name = "social"; sbtn.value = "Defaults"; sbtn.onClick = sdefaults()...

MooTools Fx.Slide throwing this.element is null

The following code is throwing the error "this.element is null". However, the wid_cont is definitely grabbing an element. window.addEvent('domready',function(){ var min = $(document.body).getElements('a.widget_minimize'); min.addEvent('click', function(event){ event.stop(); //var box = ; var wid_cont = ($(this).getParents('...

JQuery "hasparent"

The JQuery "has" method effectively selects all elements where they have particular descendants. I want to select elements based on the fact they have particular ancestors. I know about parent([selector]) and parents([selector]) but this selects the parents and not the children with the parents. So is there an ancestor equivalent of "h...