Skip to main content

Posts

Dialog Click listener not triggering in IE8 or Firefox with jQuery

I have this click listener and for some reason it's not triggering in IE8 or Firefox: console.log("listener attached"); jQuery(".ui-button-text").click(function() { console.log("this should have triggered"); var ajaxUrl = '/ajax.php?popup=true'; var dataString = "param="+param+"&param2="+param2; // contruct the ajax request jQuery.ajax({ url: ajaxUrl, dataType: 'json', data: dataString, beforeSend: function() { jQuery(".ui-button-text").html("Saving..."); }, complete: function() { jQuery(".ui-dialog-content").dialog("close"); }, success:function(response){ } }); }); So I can see the "listener attached" in the console, but I don't see the click trigger, this works in

DOM Mutation event in JQuery or vanilla Javascript

Are there any DOM mutation events in JQuery or in vanilla Javascript that fire cross browser? To clarify, say I have a script on my page which inserts a div into the body. I don't have access to the script and I don't know when the div has been inserted. I was wondering if there's a DOM mutation event that I can add a listener for to know when the div has been inserted. I know I can use some kind of timer to periodically check for the div but I don't really like the overhead that this would impose. Source: Tips4all

Showing a demo of my CSS on any website

I have developed a small component which can be put in to any website. Now, I want to develop a code that could demonstrate how would my component look like on any website. So, the person would come to my page and put in his URL and then my code should embed my custom JS/CSS in to the downloaded HTML and display it. Something like this . Here, like the feedback tab, I want to show my component any where on that page. Source: Tips4all

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()

jquery newsletter submit - loading message

i have a newsletter form i use on my site using ajax with jquery. i want to show to a user a wait message. what is the best option? heres what i have so far: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#submit').click(function(e) { $.ajax({ type: "POST", url: '/save.php', data: $('#form').serialize(), cache: false, success: function(result) { // my code when success } }); }); }); </script> <div id="newsletter"> <form id="form"> <label for="email">Your Email*:</label> <input name="email" value="" type="text" id="email" size="30" maxlength="255" /> <span id="submit">Sub

I want to show list items as 2 or more columns (dynamic alignment)

I am able to do the list using float:left; like this But I would like to show it like this (as 2 or more columns) How can I do that? @sandeep gave good solution. Unfortunately does not work in IE(need ie7 and above). any help? Source: Tips4all

jQuery Validation custom validation adding no space validation

I have a form where the user can update his name and last name. I use jQuery validation to validate the form. How can I validate if the user put spaces? here's what i have: <script> $(document).ready(function(){ $('#submit').click(function() { var valid = $("#myform").valid(); if(!valid) { return false; } $.ajax({ type: "POST", url: 'save', data: $('#myform').serialize(), dataType: 'json', cache: false, success: function(result) { // redirect to another page } }); }); }); </script> </head> <body> <form id="myform" method="post" action=""> <fieldset> <legend>update name</legend> <p> <label for="fname">Name</label> <em>*</em><input id="fname" name="fname" size="25" class="required" minlength="2" /> &