jQuery bind ajax:success not working in rails 3 app for newly created (ajax) items

**Edited this post because I found the problem is really in the inability of rails to bind to the ajax:success function. ***Using rails 3.2.3 Thanks for taking the time to read and try to help. I am adding a simple fade out function on the ajax:success of an item being deleted, as follows: $(document).ready( jQuery(function($) […]

How to create checkbox inside dropdown?

I want to create a multiple selection dropbox list. Actually I have to select more than one option using a dropdown menu. When I simply do this as shown bellow: <select> <option><input type=”checkbox”></option> </select> Then checkbox is showing in front of dropdown field. But I want to create it for each option not for as […]

appendChild Not Working

HTML: <ul id=”datalist”> </ul> JavaScript: function add(content){ ul=document.getElementsByTagName(“ul”); var li=document.createElement(“li”); li.innerHTML=content; ul.appendChild(li); } When I call add, Uncaught TypeError: Object #<NodeList> has no method ‘appendChild’ is thrown. Any idea why?

Hide div on blur

I have a jQuery function where when an element is clicked a hidden div shows. $(‘.openHide’).click(function(){ $(this).next(‘.hiddenContent’).toggle(); }); I need to modify it s that I could close this div if I click back not just on the first element. Possibly on Blur, but I am not sure how to indicate the element… $(‘.hiddenContent’).blur(function() { […]

A question about JavaScript object property name

I’ve a question about JavaScript object property name. Check out codes below: <!DOCTYPE html> <meta charset=”UTF-8″> <title>An HTML5 document</title> <script> var obj = { 123: ‘go’ // 123 is not a valid JavaScript name. No error here. }; var obj2 = { 123a: ‘go’ // An Error occurred. }; </script> If a JavaScript object’s property […]

Signalr persistent connection with query params.

I have a persistent connection which I would like to start with some seed info using query params. Here is the override in the connection. protected override Task OnConnected(IRequest request, string connectionId) { //GET QUERY PARAMS HERE return base.OnConnected(request, connectionId); } Now I have my route setup in global.asax file which looks like this. RouteTable.Routes.MapConnection(“myconnection”, […]

How to check, if a HTML5 input is supported?

I want to check in my website, if the visitors browser support a HTML5 input type. How should I do it?

Using JSHint with Express.js / 'delete' (a reserved word)

I’m using Express.js ontop of Node.js to create RESTful API, and using grunt to watch my files and automatically lint my JavaScript. Every time I use the delete function, it gets flagged by JSHint: [L218:C9] Expected an identifier and instead saw ‘delete’ (a reserved word). app.delete(‘/api/users/:userid’, function deleteUser(req, res, next) { I understand that ‘delete’ […]

How exactly does the instanceof works, and relatively, is it slow?

I’ve got 2 questions regarding instanceof: If I do john instanceof Human does the instanceof travel up the prototype chain 1 by 1 and works something like this way: var temp = john.constructor; while (true) { if (temp === Human) { return true; } temp = temp.prototype.constructor } return false; and if so, is it […]

Count unique elements in array without sorting

In JavaScript the following will find the number of elements in the array. Assuming there to be a minimum of one element in the array arr = [“jam”, “beef”, “cream”, “jam”] arr.sort(); var count = 1; var results = “”; for (var i = 0; i < arr.length; i++) { if (arr[i] == arr[i+1]) { […]