Category: Javascript

Update parent after children new windows closed

Update parent after children new windows closed

Here is a snippet to update parent after new window getting closed : 12345678910111213141516171819// Start trigger pop-up new window var createUrl = $(this).data(‘url’) + selectedUUID; newwindow = window.open(createUrl, ‘Some Page, ‘scrollbars=yes,resizable=yes,height=600,width=’+screen.width/2); // Set focus on windows if (window.focus) {     newwindow.focus(); } // Update parent once children window already closed // Reload jqgrid table …

+ Read More

Example Jquery Plugin to filtering input value real-time with Regex validation

Example Jquery Plugin to filtering input value real-time with Regex validation

We try to add real-time input validation for dynamic element with some regex. Let say, user allowed only to type “numeric” and disallow any others alphabet and symbols. Then, we can write a small plugin, at this example, i use https://github.com/akzhan/jquery-keyfilter for Regex validation. Then, we just need to write this simple and easy plugin …

+ Read More

Jqgrid for Dummies

Jqgrid for Dummies

Here is a quick snippet of how to using JqGrid for dummies, like get data, delete data, access data or data manipulation. Setup JQGrid: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970$(document).ready(function() {     // Enable tooltips $("body").tooltip({     selector : ‘[data-toggle="tooltip"]’ }); $(".chosen").chosen(); var permission = $(‘.permission’); // Define ID for table var selector = "#table-index"; var pager = …

+ Read More

JqGrid save inline editing callback

JqGrid save inline editing callback

Here is a quick snippet for callback when saving inline editing in JqGrid: 123456789101112// http://stackoverflow.com/questions/13303698/total-of-amount-in-jqgrid ondblClickRow: function (rowid, name, val, iRow, iCol) {     $(selector).jqGrid("editRow", rowid, {         keys: true,         aftersavefunc: function (rowid) {             var $grid = $(selector);       …

+ Read More

JqGrid delete multiple select rows

JqGrid delete multiple select rows

There is an issue if we delete rows using : 12345678910// Get all selected row var rows = $(selector).jqGrid("getGridParam", "selarrrow"); console.log(rows); // Iterate and delete for (var i in rows) {       console.log(i);       console.log(rows[i]);       $(selector).jqGrid(‘delRowData’, rows[i]); } Only a few records will deleted. The solution : 12345678910111213/** …

+ Read More

Solve issue Fullcalendar count two day as one day

Solve issue Fullcalendar count two day as one day

This is not bug. When we try to add day in March with start 10-03-2015T10:00:00 and end 11-03-2015T02:00:00, then it will showing one day instead of two day. To solve this issue, we need to put nextDayThreshold: 1nextDayThreshold: "00:00" To make the next day threshold every 00:00

Example make reusable javascript app for modal progress bootstrap

Example make reusable javascript app for modal progress bootstrap

This is example build reusable app in Javascript for modal progress in Boostrap: 123456789101112131415/**  * Re-usable app for modal box progress  */ var progressBox; progressBox = progressBox || (function() {     var pleaseWaitDiv =  $(‘<div class="modal hide" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false"><div class="modal-header"><h1>Processing…</h1></div><div class="modal-body"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div></div>’);     return {     …

+ Read More

How to hide search toolbar in Datatables

How to hide search toolbar in Datatables

Here is a quick snippet to hide search toolbar in datatables and working along with Bootstrap 1234var settings = {             sDom: ‘lrt<"col-sm-6"i><"col-sm-6"p>’,             serverSide : true, …

Set bootstrap datetimepicker input value date

Set bootstrap datetimepicker input value date

Here is a quick way to set value bootstrap datetimepicker input with date object: 123456$("#id_start_date, #id_end_date").datetimepicker({     format: "DD-MM-YYYY hh:mm" }); $(‘#id_start_date’).data("DateTimePicker").setDate(start); $(‘#id_end_date’).data("DateTimePicker").setDate(end);

Datatables make link in row records

Datatables make link in row records

Here is a quick snippet to make record as links in Datatables : 12345678columns : [               {                 "mRender": function ( data, type, full ) {                  // ‘full’ is the row’s data object, …

+ Read More

Jquery Datatables modify fnserverData and pagination

Jquery Datatables modify fnserverData and pagination

Here is a quick snippet for custom AJAX data for Jquery datatables : 1234567891011121314151617181920212223242526272829303132 var table = $(‘#table-index’).dataTable({                 "serverSide": true,                 "searching": false,                 "ordering": false,                 …

+ Read More

Jquery Icheck checkbox checked or not

Jquery Icheck checkbox checked or not

Here is snippet to check if checkbox is checked or not in Jquery iCheck: 12345$(‘input[name="some-input-name"]’).on(‘ifToggled’, function (event) {            if ($(this).is(‘:checked’)) {                alert(‘checked’);             }         });

The right way to use setTimeout in inifite loop Javascript

The right way to use setTimeout in inifite loop Javascript

When we using setTimeout, actually it will assigned into some parameters with ID of task. To avoid memory leaks, we should comes with this strategy. First, declare global variable. 1var timeOutClose; Let say we have infinite loop function contains : 1234// Run timer to close box timeOutClose = setTimeout(function() {     $(".md-close").trigger("click"); }, animationClose …

+ Read More

Beware with jquery animate in infinite loop Javascript caused memory leaks

Beware with jquery animate in infinite loop Javascript caused memory leaks

After do Check memory leak javascript in Chrome, i found that animate and delay in Javascript quite consume memory. And it’s end up with memory leaks. Here are my code : 1234567891011121314151617181920for (var i = 0; i < split; i++) {     …     $("tr.cmp_tr").css({         ‘display’ : ‘none’   …

+ Read More

How to insert javascript code into WordPress from plugin using shortcode

How to insert javascript code into WordPress from plugin using shortcode

When we need to inserting Javascript blocks code programmatically into post, we know that WordPress autoescaping Javascript before write into tables. To make javascript inserting into post in WordPress, we can use shortcode. This feature meaning we define custom tag blocks in post and how to convert it tag. So, the tricks is we should …

+ Read More

Solving no docs found for member gjslint on VIM Syntastic

Solving no docs found for member gjslint on VIM Syntastic

Closure Linter (gjslint) is pretty powerfull for checking our javascript code. If you using VIM, then you should consider using Syntastic plugin which is incredibly. By default, Syntastic will detecting Gjslint, Jslint, JSHint and Javascriptlint in our system. Every editing and saving a JS file, syntastic will do several javascript checker. Today, i found “no …

+ Read More

Modify Jquery Typing disable enter key / some key from start event

Modify Jquery Typing disable enter key / some key from start event

I have chat applications based on NodeJS that using Jquery-typing for detecting user activity. This plugin is great, but i facing some problem with enter keys. I make some script if user press “ENTER”, it will send message. But seems Jquery-typing detect “ENTER” key as start typing activity. It will make my chat application give …

+ Read More

How to get select value using Jquery

How to get select value using Jquery

Simple things, we want to grab value from select button on Jquery. If you want to get option value of select list, use this : 1$(‘select :selected’).val(); If you want to get text value in select list, use this : 1$(‘select :selected’).text();

Auto remember form input content while typing using JQUERY

Auto remember form input content while typing using JQUERY

When clients inserting data into form, suddenly their connection lost or accidentally refreshed the web page. And guess what? they facing new empty form again and feel tired to inserting same data again. We can reduce this by using JQUERY cookies which can remember what clients type into form. So, when they refreshed pages even …

+ Read More