Javascript

Is there a better way to do this? I'm using the underscore js lib here, which is where the _. comes from. I'm used to this sort of procedure to format strings in python and i'd like something simple for javascript without doing + + + + all the time. This works, but it feels like i reinvented the wheel. function foo (iterable, string) { var s = iterable.shift(); string = string.replace("%s",s); return _.isEmpty(iterable) ? string :
I want to get class .mGMZs in input name=age with .closest, I try it in following demo but i doesn't work as expected, how can I fix it? <div class="age"> <div class="column"> <input name="age[0][]" class="mGMZs" placeholder="Age(Geting class this)"> <div class="p_age"> </div> </div> <br /> <button>Click Me</button> </div> $('button').live('click', function () { var class_age =
I'm using the Embedly API with this code: $.embedly('http://www.youtube.com/watch?v=LfamTmY5REw', {maxWidth: 600, elems: $('#element'), success: function(oembed, dict){ alert(oembed.title); }); Now my question is where should I put this code in my ruby on rails directory? In my application.js file? And how do I call this code when a url is submitted via a form? Take a look at the embedly examples, specifically
For debugging I want to serialize javascript objects with JSON.stringify(myobject). But this gives: TypeError: Converting circular structure to JSON Is there a way to prevent this, by for instance pruning the output tree? Some more background: I want to collect some data on different objects and see what is going on, and why a feature works for one situation but not for another. By comparing outputs I hope to be able to find differences which explains why it is not working in
I have a Windows Communication Foundation service which queries the Entity Framework and retrieves data in the form of Entity objects. I'd like to serialize these objects to JSON and send them back to the client to be interpreted in Javascript. It seems this is tricky, according posts like these: http://bloggingabout.net/blogs/progr...tion-woes.aspx At this time, what's the best way of doing this using Visual Studio 2010 Beta 2? Data transfer objects are one way but is there
function loaded() { document.addEventListener('touchmove', function(e){ e.preventDefault(); }); myScroll = new iScroll('scroller'); } document.addEventListener('DOMContentLoaded', loaded); If its possible... Thanks :) $(function() { $(document).bind('touchmove', function(e) { e.preventDefault(); }); var blah = new iScroll('scroller'); }); i believe this would work.
I am calling to a restAPI through jquery.ajax call() once it completed i cannot use my other ajax calls hence i am thrown away from the spring security. i noticed the JsessionID change upon complete the restAPI call (i used httpFox plugging for fire fox). so what ever i am doing after the rest API call i will redirect to the Login page by spring security. i noticed that i am not authorized user anymore. i thought if i can keep the initial 'jsessionID' and use it through my browser it
Looks like it's easy to add custom HTTP headers to your websocket client with any HTTP header client which supports this, but I can't find how to do it with the JSON API. Yet, it seems that there should be support these headers in the spec. Anyone has a clue on how to achieve it? var ws = new WebSocket("ws://example.com/service"); Specially, I need to be able to send an HTTP Authorization header. No There is no existing method in the JavaScript WebSockets API for
Possible Duplicate: Data transfer from JavaScript to PHP. How can i get the browser's height and width to php? Like a data transfer from javascript to php? With using innerHeight and InnerWidth, i think. (I just need to show user small picture if he has small screensize and big if big and without a data about screensize i cant do it) I have like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
I'm currently working on an inherited project which uses Google's Visualization API (for both Python and Javascript). Since parsing the data for Gviz takes a while, I'm trying to let the page fetch a loading image and display it while the relevant charts are loading via AJAX calls. While I could be wrong, I believe that I have been coding it correctly; below you can find the relevant code, which I have inserted into the <head> portion of the page. $(function() { var dates =
I have something like this: <select class="bla"> <option value="1">...</option> <option value="2">...</option> </select> <select class="bla"> <option value="1">...</option> <option value="2">...</option> </select> <select class="bla"> <option value="1">...</option> <option value="2">...</option> </select> <input class="alloptions" type="hidden" value=""> I
I am new to javascript and have a very basic question: I have this in my HTML Total Cost: <input type="text" name="total" id="total" class="MyInput" /> I want to assign a value to this textbox at the program startup, for that I am using document.ready, but its not working. <SCRIPT LANGUAGE="JavaScript"> $(document).ready(function() {{ $("#total").value = "2"; }); What is the correct way of doing this? Do: $(document).ready(function(){