javascript

Need help in highlighting the text in rails

Hi, I have built a free text search engine in rails ,I want to highlight search word in result page where, each word in the phrase may not be adjacent to each other( that is they may be present in any part of the text content). I have tried with highlight method of ActionView::Helpers::TextHelper as <%= highlight(content.body, @search_k...

Override Javascript Function Based on Passed Parameters

Is it possible to override a function based on the number of parameters that you are passing into it? For instance: function abc(name) { document.write ('My name is' + name); } function abc(name,friend) { document.write ('My name is' + name + 'and my best friend\'s name is' + friend); } So in the HTML if I just called abc(ge...

Changing save directory

Disregard my previous pre-edit post. Rethought what I needed to do. This is what I'm currently doing: https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIScriptableIO downloadFile: function(httpLoc) { try { //new obj_URI object var obj_URI = Cc["@mozilla.org/network/io-service;1"].getService(Ci...

Positioning SVG Elements

In the course of toying with SVG for the first time (using the Raphael library), I've run into a problem positioning dynamic elements on the canvas in such a way that they're completely contained within the canvas. What I'm trying to do is randomly position n words/short phrases. Since the text is variable, its position needs to be vari...

Posting form using javascript and json with nested objects

I have an html form that has the following structure: <input type="text" name="title" /> <input type="text" name="persons[0].name" /> <input type="text" name="persons[0].color" /> <input type="text" name="persons[1].name" /> <input type="text" name="persons[1].color" /> I would like to serialize this into the following json: { ...

Display dynamically created php image after POSTing data

I have a php script which outputs an image, how can I POST data to it and display the resulting image without refreshing the rest of the screen, so far I have got the code below which returns a png. function go(){ $.post("test_image.php", $("frm").serialize(), function(data){ //alert(data);//proves a png image is returned. ...

Confused with ECMAScript Language Specification Function Calls section

Hi, I am reading ECMAScript Language Specification Function Calls section Can someone rephrase or detailed explains the following sentense for me? The production CallExpression : MemberExpression Arguments is evaluated as follows: Evaluate MemberExpression. let's take this code as an example. var john = { name:...

JQuery: how to use "delegate" instead of "live"?

I've read countless articles how using the JQuery delegate is much more efficient than using the "live" event. As such, I'm having trouble converting my existing Live code to using Delegate. $("#tabs li:eq(0)").live('click',function(){ //...code }); $('#A > div.listing, #B > div.listing, #C > div.listing').live('mouseover',function(){ ...

Multiple click events

I have some popup dialogs on my webpage, in each of this dialogs i have defined some click event with jquery : $(".links_view").click(function(e){ //code }); But the problem is when i activate one this click event, it will be executed in each dialog... ...

Using jQuery and AJAX works for all functions except one, really bizarre issue (from my perspective).

I am working on a classic asp form that has a number of dropdowns. Three of these are cascading, i.e. they rely in the previous dropdown. For almost everything this code works fine, one of them however is not playing nice. To start off I have a script tag with the following in it: $(document).ready(function () { $("#Academ...

Access element in json having numerical index

i have following format of json in which i want to asscess 0.4 , kem , 2 , 2000 values but it seems it doesn't have name index so how one can access it in jquery. when i paste following code in json viewer then i am getting numerical index for 0.4 , kem , 2 "td": [ { "@attributes": { "class": "odd" }...

Autorefresh div/table in Django if new queryset records available

Hello, I'm using Django and I would like to check if there are new records in queryset (which I display in table) and if there are new I would like to either update my table accordingly with fade effect or display most recent 5 records in another div/box. I've used jquery autorefresh, but it fades in / fades out even if there are no n...

Javascript error when integrating django-tinymce and django-filebrowser

I've set up django-filebrowser in my app without any bugs, I already had django-tinymce set up and it loads the editor in the admin forms. I now want to use django-filebrowser with django-tinymce, but I keep getting a weird javascript error when I click on "Image URL" in the Image popup: r is undefined the error is js/tiny_mce/tiny_mc...

AJAX function to POST 4 variables

Ive been having great frustration for hours now trying to remember my AJAX! Im trying to write a function which will be called that will simply POST 4 variables to a given URL, written in javascript and not jquery such as: function postVariables(URL, var1, var2, var3, var4) { ...... return true; } Can anyone help? ...

Property value of a String object in JavaScript

As far as I understand, every string is an object in Javascript. Still, it "does not work" as I expect it to be: var a="abc"; //here we get a new string object a.b = 123; //I seem to declare a property "b" of that object alert(a.b); //alerts "undefined" However, if I try to define a string in the "wrong way", everything works as...

ASP.NET: Why is my JavaScript object set to null?

I have a <script> that contains this line: var tbl = document.getElementById("<%= this.tblSelection.ClientID %>"); ... but tbl always ends up being set to null. The table is declared like this: <asp:Table ID="tblSelection" runat="server" CellPadding="2" CellSpacing="0" cols="1" style="position: absolute; top: 0%; right: 0%"> ...

Rails fails to return scripts/stylesheets

This only happens on my local machine (Windows 7, Ruby 1.8.7). Occasionally rails will just stop returning my stylesheets/javascript and I'll get gross looking pages. If I navigate directly to those scripts, sometimes they work, and sometimes I get errors like: private method `gsub!' called for #<Class:0x76ff830> What could be causing...

Strange problem with Page Method JSON result.

I have the following JavaScript to populate a dropdown. When I single step into populateResourceList, the value for jsonList is shown below the code. However, this method fails on the for statement with the error jsonList.Table is undefined What am I doing wrong? function populateResourceList(jsonList) { var listItems = "...

Add another class to a div with javascript

I have a function that checks the age of a form submission and then returns new content in a div depending on their age. right now I am just using getElementById to replace the html content. BUt I think would work better for me if I could also add a class to a div as well. So for example I have.. if (under certain age) { document...

Watching setTimeout loops so that only one is running at a time.

I'm creating a content rotator in jQuery. 5 items total. Item 1 fades in, pauses 10 seconds, fades out, then item 2 fades in. Repeat. Simple enough. Using setTimeout I can call a set of functions that create a loop and will repeat the process indefinitely. I now want to add the ability to interrupt this rotator at any time by clicking ...