javascript

javascript firebug error

I have a javacript code coupon.js defined as follows - jQuery(document).ready(function(){ jQuery('.appnitro').submit( function() { $.ajax({ url : $(this).attr('action'), type : $(this).attr('method'), dataType: 'json', data : $(this).serialize(), success : function( data ) { for(var id in data) { jQuery('#' + id).html( data[id] ...

Javascript add events cross-browser function implementation: use attachEvent/addEventListener vs inline events

In order to add events we could use this simple 1st solution: function AddEvent(html_element, event_name, event_function) { if(html_element.attachEvent) //Internet Explorer html_element.attachEvent("on" + event_name, function() {event_function.call(html_element);}); else if(html_element.addEventListener) //Firefox &...

Proper way of getting several scripts asynchronously using Jquery with post-document-ready callback

I'm planning on getting several JS files from my server asynchronously while the page loads. I am aware of the Jquery function "getScript", but this only gets 1 script. Is there any way of specifying a callback to be executed when a batch of scripts have been fetched from the server? I thought about doing something like this: $.getScr...

Need help to understand the usage of ":" in JavaScript

I'm using jQuery validate plugin, and when I met the following script, i recognize, that i don't understand many things in jQuery:) Look please $("#invitationform").validate({ rules: { phone: List item { required: true, minlength: 6, number:true } ...

ASP.net MVC put complex data (array) to controller method

I'm porting an ASP.net Web Forms application to MVC. The application uses AJAX, by means of Ajax-enabled WCF Web service and asp:ScriptManager. I send an array of objects for service, it handles it just great. Code example, <script type="text/javascript"> $().ready(function () { var ser = new Services.TasksService(); ...

Variable Scope help: this.reset() is not a function

when save() executes this.reset() or that.reset() it can't find the reset() method and says it's not a function. I used a workaround on init() to get it to work, but that method didn't work in save() var vehicle = function () { return { init: function () { var that = this; jQuery('.vehicle-year-prof...

Cancel escape-sequence on JavaScript

We can work with escape sequence in strings on JavaScript. For example, I can write \\ and it means \. But I don't want to use a escape sequence. I know that on C# I can write @"My string" and I don't need to escape anything. Is there similar syntax in JavaScript? ...

Access filesystem using js within grails project

Hi For learning purposes I created a toy project using grails. In this project I would like to play an mp3 file in one of my views. I found an html5/flash mp3 player. But when the music is supposed to play, I have a question. The HTML 5 player is in the project/web-app/js folder. Everything else is in its normal place. When I try to acc...

Best way to redirect to a hashed version of a URI?

So all of the pages on my web application have URIs of the form http://www.example.com/#some-hash and the like. But of course, if the user visits http://www.example.com/some-hash they should get redirected and experience the site in its usual glory. OK, no problem, right? Just write some kind of global HTTP request interceptor that auto...

Javascript to loop through all asp:Hyperlink controls on a page, and hide them

I have a master page which has a DIV with asp:Hyperlink controls functioning as the menu for the site. When I'm on a certain page if (document.title = 'Certain Page'), I want javascript which will loop through all asp:hyperlink controls on the page and hide them (i.e. set to not visible). I know I could probably do this on the server s...

Adobe InDesign JavaScript XML: How to add XML structure tags programmatically?

This code references the root XML node, adds a FirstXMLObject under it, then adds a few fields under FirstXMLObject: var myXMLroot = mydocument.xmlElements.item(0); // The root always exists var b = myXMLroot.xmlElements.add( "FirstXMLObject"); b.xmlElements.add( "Name", "Bob"); b.xmlElements.add( "Address", "1234 Sesame Lane"); Supp...

General tips for semantically cleaning up HTML, CSS & JS?

As I've gotten deeper into using jQuery with various sites I've worked on, I've found that I can get lost on whether a class attribute value is appended to an element in the DOM in order to attach an actual CSS style, or to bind an event to it. As such, I've started leaning towards using the rel attribute on anchor tags to denote if som...

Can Flash's print action be triggered from JavaScript?

Is it possible to use JavaScript to trigger a Flash object's context-menu 'Print' action? Background: I have a page whose main content consists of a Flash object. I need to print this page via JavaScript, which I'm doing with window.print. Unfortunately, it seems that Firefox has a bug (for the past eight years) whereby Flash content ...

How do I make a j-query photo gallery slider play nice with duplicate slider?

Hello, First off, I am very new to j-query. That being said, I have a very simple j-query photo gallery slider that holds images and fades into new ones every few seconds. I have a page where I duplicated it, and gave it different css and class/id names in the js to make a different one. I want both on the same page. Now that I have the ...

How do I figure out the type of exception I'm getting if I get a read error using Ext.data.DataProxy?

I'm using an Ext.data.JsonReader defined like so: new Ext.data.JsonReader ( { totalProperty: 'totalCount', successProperty: 'success', idProperty: 'id', root: 'data', messageProperty: 'message' }, [{ name: 'id' }, { name: 'a'}, { name: 'b'}, { name: 'c'}, {name: 'd'}, {name: 'e'}, {n...

Add textbox value to listbox on tab

II am working website which is going to be accessed by a motorola device(scanner) but the functionality needs to be same a normal/usual website. On one of the page I have a textbox -> productID and listbox which can have multiple productID. Now when the focus is on textbox and it scans the productID ,the scanner returns a tab,now after ...

Offering a file "save as" dialog after an HTML form submit

I have a JSP page that needs to accept some info into a form, having said form submit to the same page with an extra "Thanks for __" div that is placed only after the form submit (using a parameter check). However, I also need to serve up a file on the server for download, but I can't mess with the header's content-disposition to serve...

JavaScript Regular Expression to validate an address

I am trying to modify this script to accept , - and ' for this regex to validate addresses on a form is it written correctly? ^[a-zA-Z0-9\s\,\''\-]*$ ...

Best method to repeat JS function

Sometimes this function can be called too quickly and multiple elements are created but since it uses an ID that's not unique to each instance it the part to fade out and remove the div only applies to the top level element, not all of them. So I end up with a static div tag that isn't fading/removing. The best thing I can think to do ...

Get list of dates within a span with javascript

I'm looking for a js (or jQuery) function where I pass a start date and end date, and the function returns on inclusive list (array or object) of each date in that range. For example, if I pass this function a date object for 2010-08-31 and for 2010-09-02, then the function should return: 2010-08-31 2010-09-01 2010-09-02 Anyone have a ...