How to prevent user to enter text in textarea after reaching max character limit

The keyup event fires after the default behaviour (populating text area) has occurred. It’s better to use the keypress event, and filter non-printable characters. Demo: (with max length 4) jQuery(document).ready(function($) { var max = 400; $(‘textarea.max’).keypress(function(e) { if (e.which < 0x20) { // e.which < 0x20, then it’s not a printable character // e.which … Read more

How do I implement Toastr JS?

Toastr is a very nice component, and you can show messages with theses commands: // for success – green box toastr.success(‘Success messages’); // for errors – red box toastr.error(‘errors messages’); // for warning – orange box toastr.warning(‘warning messages’); // for info – blue box‘info messages’); If you want to provide a title on the … Read more

Understanding promise.race() usage

As you see, the race() will return the promise instance which is firstly resolved or rejected: var p1 = new Promise(function(resolve, reject) { setTimeout(resolve, 500, ‘one’); }); var p2 = new Promise(function(resolve, reject) { setTimeout(resolve, 100, ‘two’); }); Promise.race([p1, p2]).then(function(value) { console.log(value); // “two” // Both resolve, but p2 is faster }); For a scenes … Read more

How to use JQuery with Master Pages?

EDIT As @Adam points out in the comments, there is a native jQuery mechanism that basically does the same thing as the hack in my original answer. Using jQuery you can do $(‘[id$=myButton]’).click(function(){ alert(‘button clicked’); }); My hack was originally developed as a Prototype work around for ASP.NET and I adapted it for the original … Read more

update markercluster after removing markers from array

Yes you can. Creating the map Assuming you have created your MarkerClusterer object something like this: var center = new google.maps.LatLng(10, 20); var map = new google.maps.Map(document.getElementById(‘map’), { zoom: 6, center: center, mapTypeId: google.maps.MapTypeId.ROADMAP }); var markerClusterer = new MarkerClusterer(map); Adding markers You can add multiple markers to it something like this: var markers = … Read more