javascript

How to extend a jquery ui widget ? (1.7)

I would like to create a custom version of the sortable widget. I have been searching for documentation, but could not find something really accurate. The best information I found was : http://jqueryui.pbworks.com/Widget-factory. I tried : $.widget("ui.customsortable", $.extend($.ui.sortable, { _init: function() { $.widget.protot...

JSCharts - How to Hide Axes

Hello All, I'm currently using JSCharts to chart some data, however, I'm not quite sure how to hide the axes. Maybe I'm overlooking something in the reference documentation (see http://www.jscharts.com/how-to-use-reference) but I can't seem to find it!~ myChart.setAxisWidth(0); //works in Firefox but not Chrome Thanks in advance! ...

Breaking a PHP code with Javascript confirm dialog?

I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo "<script type='text/javascript'> var r = confirm('Input cost is lower than original. Sure?')); If (r==true){ } else{ *** BREAK PHP SCRIPT *** } </script>"; } And I'd like to...

JS/jQuery: Trying to fit an ambiguous text string within a certain width through substr

Hi, I'm trying to take a text string, (e.g. the word "testing") and calculating if the string, when displayed on screen, will exceed a certain width. I do this by putting it in a element and using width(). Now, the thing is I want to reduce the text string by a character at a time, and then determining the width. If the width is withi...

What is cached on a client machine when using https.

I have an application that is working on https for everybody and on http for all but two users. The two users get a JavaScript error when trying to "edit" a page while on http but can edit the page on https. The problem is for occurs for both IE6 and FF3.6 for one of these users. Others have no problem using any browser. I have used ...

Is there way to extend jQuery to handle a custom enter key event?

I write the following code all the time to handle when the enter key pressed: $("#selectorid").keypress(function (e) { if (e.keyCode == 13) { var targetType = e.originalTarget ? e.originalTarget.type.toLowerCase() : e.srcElement.tagName.toLowerCase(); if (targetType != "textarea") { e....

how to handle single quote in $.ajax POST (JQuery)?

.ajax({ type: 'POST', url: '..serverices/ajaxserver.asmx', data: 'lname='+ $('#lastname').val() }); return false; if #lastname has a single quote, it throws an error. How to handle it? ...

After .load() Reset Textbox with User Entered Value using JavaScript and jQuery

My function below calls a partial view after a user enters a filter-by string into the text box '#DocId'. When the user is done typing, the partial view is displayed with filtered data. Since my textbox needs to be in the partial view, when user is done entering a filter-by string and is shown the filtered data, the textbox is reset an...

Javascript - is it bad to pass more arguments than the function declares?

I have a function function callback(obj){...} Is it okay to pass in more objects than were declared in the function signature? Eg, call it like this: callback(theObject, extraParam); I tried it out on firefox and it didn't seem to have a problem, but is it bad to do this? ...

Passing a Smarty variable into Javascript link "src" attribute

I've assigned a Smarty variable: {assign var="siteurl" value="http://website.com"} I can successfully use it in my header.html file to call a CSS link: <link rel="stylesheet" type="text/css" href="{$siteurl}/style.css" /> displays <link rel="stylesheet" type="text/css" href="http://website.com/style.css" /> However, when I do th...

Security precautions and techniques for a User-submitted Code Demo Area

Hey folks Maybe this isn't really feasible. But basically, I've been developing a snippet-sharing website and I would like it to have a 'live demo area'. For example, you're browsing some snippets and click the Demo button. A new window pops up which executes the web code. I understand there are a gazillion security risks involved in...

javascript pausing consistently. How do I find what is causing it to pause?

I've got a fairly ajax heavy site and I'm trying to tune the performance. I have a function that runs between 20 & 200 times, depending on the user. I'm outputting the time the function takes to execute via console.time in firefox. The function takes about 4-6ms to complete. The strange thing is that on my larger test with 200 or ...

(interactive) graph as in graph theory on a web page ?

Hi, I have to integrate a graph with nodes and edges on a web page. Ideally, i would like to be able to interact with it (like moving the nodes around). Actually, i'm beginning by representing trees, so i would appreciate to be able to collapse subtrees. How can I do that ? I was considering google-visualization api but i wasn't able ...

Calling methods within same JavaScript class [Prototype]

I've created a class in Javscript using the prototype Class.Create complete with the initialize function and a few other functions. However, in one of my functions I want to reference another function in the same class, but cannot seem to get the syntax correct. e.g. var sampleClass = Class.create({ initialize: functi...

adding to json property that may or may not exist yet

let say i want to do this var dasboard = {}; var page = "index"; $('.check').click(function(){ $(this).toggleClass("active").siblings().slideToggle('slow', function() { dashboard['pages'][page][$(this).closest('li').attr("id")]['show'] = $(this).is(":hidden") ? 'collapsed' : 'expanded'; }); } i get an error s...

Copying values of one table to another (how to convert this js function to jQuery)

Hi All, I am stuck with a small problem here.. What i am trying to do is copy description of id's from one table to another. I have writter half of the javascript and can anybody tell me how to convert this function in jquery. I want the description copied from the first table based on the id to the second table. Have done this in jquer...

Simple javascript string problem in ie6 and ie7

I have a very simple function that takes a list of comma separated (x,y) points and imports them into a graph. I have FF, Chrome and IE8 installed. I use IETester to test for IE6 and IE7. // Import Data this.Import = function(data) { alert("Data in: "+data); var d; // Make sure the first and the last are start/ending pare...

jQuery not working on Popup Window

I am using ASP.Net and jQuery + jQuery UI. Everything works fine with the jQuery on any other page, however when I create a popup window with window.open(...) jQuery seems to no longer function. I have all of the script files included on the Popup's Master page, so am not sure why it won't fire. Any Thoughts? ...

Getting just the filename from a path with Javascript

I have a full path to an image, which I am using jquery to read, in the form $('img.my_image').attr('src') however I just want the filename portion (discarding the path). Are there any built-in functions to do this, or would a regex be the only option? ...

How to format JSON date in Javascript?

I'm passing a date from Ruby to Javascript via JSON. It comes into Javascript as "2010-03-24T10:00:00Z". Now, how the heck do I format that in Javascript? ...