Check if a class `active` exist on element with jquery
I think you want to use hasClass() $(‘li.menu’).hasClass(‘active’);
I think you want to use hasClass() $(‘li.menu’).hasClass(‘active’);
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: http://jsfiddle.net/3uhNP/1/ (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
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 toastr.info(‘info messages’); If you want to provide a title on the … Read more
In the current version of DataTables (1.10.4) you can simply add destroy:true to the configuration to make sure any table already present is removed before being re-initialised. $(‘#example’).dataTable({ destroy: true, aaData: response.data });
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
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
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
As far as I know, you can only get the array by hard-coding it. var monthNames = [ “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” ]; Or you can use some javascript library which has this list hard-coded.
input.keydown(function(event){ if (event.keyCode === 9) { event.preventDefault(); } }) On keyup is too late, you need to call the event on keydown. That worked for me.
Here’s a hopefully bug-free version, updating as you drag. It’s generating the current desired positions of the items when sorting starts, which means you should be able to change the classes whenever you need, refresh the widget’s list items and you’re good to go. It also uses the sortable’s built-in items property to prevent dragging … Read more