Friday, May 29, 2015

Update Linux servers





Recommend once per month to update Linux web servers:
sudo yum check-update
sudo yum update
to reboot
sudo shutdown -r now

autocomplete in notepad++




Auto-Completion in notepad++ is enabled by a checkbox via settings in Settings -> Preferences -> Auto-Completion. You accept the suggestion by typing Enter or Tab. you can use the Down- & Up-arrow keys, or PageDown & PageUp, to move through the list; or, type Esc to dismiss the list.

Tuesday, May 26, 2015

Freeze submit button when waiting ajax post data




When we update a input box from ajax post, it may delay. When users click the submit button, the old data will be posted.  We need to freeze submit button when waiting ajax post data.

Example:
$('#universalModal .modal-body input[name="StudentID"]').val(Obj.student_num);
$('#universalModal .modal-footer button#submitBtn').html('Save and Exit');

                   $('#universalModal .modal-footer button#submitBtn').prop("disabled", true);
                   $.post(url, postdata, function(data){
                        $("input[name='StudentID']").val(null);
                       $('#universalModal .modal-footer button#submitBtn').prop("disabled", false);       
                     }
                 });   



When the submit button is enables and we click submit button, the StudentID value is update from ajax post. Now we can post all form data vi submit.

Difference between set empty and set null in jquery input value





I posted form data in Modal form using $('form#populate').serializeArray().
I manually set an input text box empty
         $("input[name='StudentID']").val(' ');
 But when I use PHP empty function, the post data from StudentID is not empty. I used Network in web developer tools in Firefox and see the post data is "+". (Although finally it will transfer to empty string)
Finally I set it as null
        $("input[name='StudentID']").val(null);
The post.data is " " in web tools and make empty function judges correctly.

Saturday, May 23, 2015

Trigger a click in jQuery




To trigger a click in jQuery, for example id stakeholderAccesses:
   $('#stakeholderAccesses').click();
 I found following trigger function not working well:
 $('#stakeholderAccesses').trigger('click');
Complete example:
$(document).ready(function() {

        //Display and Load the body part when the header is clicked.

        $('#stakeholderAccesses').click(function() {
                if( $(this).parent().children('div').css("display") == "none" ) {
                        $(this).html( '-' + $(this).html().substring(1) );
                        $(this).parent().children('div').load('../_ajaxParts/CVS/CVS_Access.php', {sid: $.url.param('sid')}).show('fast');
                }
                else {
                        $(this).html( '+' + $(this).html().substring(1) );
                        $(this).parent().children('div').hide('fast');
                }
        }).hover(function() {$(this).css('cursor','pointer');},function() {$(this).css('cursor','auto');});

         $('#stakeholderAccesses').click();
});