javascript

jQuery index selector

Hi, I'm trying to find out a way to know the index of a anchor tag inside a certain div (one div has multiple similar anchor tags), like this : <div> <a>first</a> <a>second</a> <a>third</a> </div> I'm using jQuery, but so far found no sollution to find the index of the anchor I have the mouse currently over. Any ideas? Cheers...

link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?

i am wondering if the basic link_to syntax is completely broken in current rails3 master or if i am doing some wrong syntax here. = link_to "name", nil, :onlick => "alert('Hello world!');" should actually produce an alert on click. very simple. does not work on my rails3 project! (also no error output!) any ideas? for the general lin...

How to make an element slide with the viewport as it scrolls?

I've Googled for this but must be using the wrong keywords. Basically I want to use the effect that Magento and now Stack Overflow uses. That is, there is an element in a column, and when you scroll down, it sticks to the top of the viewport. And once scrolled up again, it goes back into the normal page flow. This Ask A Question is a g...

Can I get the "value" of an arbitrary statement in JavaScript (like eval does, but without eval)

In JavaScript is there a way to get the "value" of a statement in the same way that function() { return eval("if (true) { 1 }"); } returns "1"; function() { return if (true) { 1 } } and all similar permutations I've tried are not valid syntax. Is eval just blessed with special powers to determine the "last" value of a statement in an e...

Alternative to jQuery's .toggle() method that supports eventData?

The jQuery documentation for the .toggle() method states: The .toggle() method is provided for convenience. It is relatively straightforward to implement the same behavior by hand, and this can be necessary if the assumptions built into .toggle() prove limiting. The assumptions built into .toggle have proven limiting for my curren...

Chinese/japanese characters in a search box and form.

Why is it that when I use Firefox to enter: 漢, the GET will transform to: q=%E6%BC%A2&start=0 However, when I use IE8 and I type the same chinese character, the GET is: q=?&start=0 It turns it into a question mark. ...

How to edit a link within a contentEditable div

Does anyone have any suggestions on how to edit an link in a contentEditable div? It would be ideal once the link is either clicked with mouse, or the cursor hits the link, that the a small prompt would pop up and allow the user to change the href property of the link. The prompt isn't the issue, but how is it possible to detect the lin...

How to position an element so that it does not flow off the visible screen

I am creating pseudo-tooltips on a page that has a lot of "a" and "span" elements that have these tips associated with them. Everything in the creation of the element is fine, and it displays fine. However, since this is a page with a lot of data, as you get towards the bottom of the visual area the tooltips start to flow past the botto...

jquery ui tabs major style change

I am using jquery UI tabs and I need to majorly change the styling on it. I need to rempve the background image, the borders, almost everything. I need it to look minimal, and not like it's self contained. What's the best way to do this? I need to use the default UI styling for the calendar widget however, which is on the same page. ...

How to copy text to clipboard in Firefox 3.5?

How can you copy text to clipboard using Javascript (or even nicer a jQuery function) without involving Flash? I don't care about IE and other browsers; Firefox 3.5 is the only browser that matters changing local FF settings is OK. Edit: Sorry for being unclear, I did try out the first 30 methods I found via Google; none of them worked...

How do you access the main obj from obj.foo.bar in javascript?

Objects in javascript throw me for a loop! In this set up... var obj = { someVar: "my awesome variable", foo: { bar: function(){ alert(this.someVar); } } }; How would I get obj.foo.bar to correctly alert the value of someVar? ...

How to specify a style not to be overriden by styles specified in JS

Hi guys: I got some elements whose style is dynamically modified by a JS. However, I hope one of which would not be modified. How could I specify its style, which is static, not to be overriden anyway. Thanks. ...

What is target="_new"? validator giving error..

What is target="_new"? Validator is raising an error.. How do you do this with jquery because Validator is raising an error. On the same page, I have target="_new" and target="_blank". target="_new" is in that form code which i received from email newsletter company. I'm using this for target="_blank" $(function() { $('a[href^...

Prevent backslash from being parsed by javascript for a string

A Flash AS3 IRC application sends me a string like "f\reak" to my javascript. Irc allows the \ in usernames which poses a problem when its passed to javascript. "f\reak" become "feak" in javascript making the \r into a carriage return. Is there a way to read the absolute value of the string instead of parsing a carriage return? These don...

Not all parameters get sent in jquery ajax call

I have a strange error where my jquery ajax request doesn't submit all the parameters. $.ajax({ url: "/ajax/doAssignTask", type: 'GET', contentType: "application/json", data: { "just_a_task": just_a_task, "fb_post_date": fb_post_date, "task_fb_postId": task_fb_postId, "sedia_task_guid": ...

Javascript issue on IE

I have added the social links in my html page. When I added, the top nav of my pages is gone. Tats appeared in firefox but not in IE. Any one help me how can i resolve tis? Here is the code i used. <a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4b9a190d10b004d6"&gt; <img src="http://s7.ad...

twitter's profile widget include in a separate javascript file

Hi stackoverflowers, I'm just trying to put the custom twitter's profile widget on my page, but I like to put the code in a separate javascript's file. so, I don't know how to do that. I mean, I put this on head tag <script type="text/javascript" src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt; the create a div for t...

Utilising cssText to set styles with JavaScript

I was going through Nicholas Zakas presentation on JavaScript here : http://www.slideshare.net/nzakas/writing-efficient-javascript (slide number: 89/139) He recommends using cssText property whenever you are setting a bunch of styles through JavaScript. The best solution is obviously adding those styles to a class and then using JS to a...

CSS Semi-fixed Element?

I remember seeing an example of this recently, but for the life of me I can't find the site. It was a button or something similar that sat in its place near the top of the screen, then when you scroll down it stays on screen. Now that I think about it, it must have been javascript-powered, but it looked really natural. Does anyone kno...

How to Create Multilevel jquery accordion menu using jQuery?

I want to create multilevel accordion Navigation using jQuery , I tried using this script but it not allow the multi-level. Please view the Image what exactly I am looking for, http://www.i-marco.nl/weblog/jquery-accordion-menu/# Thanks ...