Sunday, December 7, 2014

Different ways to call JQuery Document Ready functions

These are the different types of Document Ready functions typically used in jQuery (aka jQuery DOM Ready). A lot of developers seem to use them without really knowing why. So I will try to explain why you might choose one version over another. Think of the document ready function as a self-executing function which fires after the page elements have loaded.
See Where to Declare Your jQuery Functions for more information on how to use the Document Ready Functions.

Document Ready Example 1

$(document).ready(function() {
    //do jQuery stuff when DOM is ready

Document Ready Example 2

    //jQuery code here
This is equivalent to example 1… they literally mean the same thing.

Document Ready Example 3

jQuery(document).ready(function($) {
    //do jQuery stuff when DOM is ready
Adding the jQuery can help prevent conflicts with other JS frameworks.
Why do conflicts happen?
Conflicts typically happen because many JavaScript Libraries/Frameworks use the same shortcut
name which is the dollar symbol $. Then if they have the same named functions the browser gets
How do we prevent conflicts?
Well, to prevent conflicts i recommend aliasing the jQuery namespace (ie by using example 3 above).
Then when you call $.noConflict() to avoid namespace difficulties (as the $ shortcut is no longer available)
we are forcing it to wrtie jQuery each time it is required.
jQuery.noConflict(); // Reverts '$' variable back to other JS libraries
jQuery(document).ready( function(){
         //do jQuery stuff when DOM is ready with no conflicts
//or the self executing function way
 (function($) {
    // code using $ as alias to jQuery

Document Ready Example 4

(function($) {
    // code using $ as alias to jQuery
  $(function() {
    // more code using $ as alias to jQuery
// other code using $ as an alias to the other library
This way you can embed a function inside a function that both use the $ as a jQuery alias.

Document Ready Example 5

     //initialize after images are loaded 
Sometimes you want to manipulate pictures and with $(document).ready() you won’t be able to do that
if the visitor doesn’t have the image already loaded. In which case you need to initialize the
jQuery alignment function when the image finishes loading.

Thursday, November 6, 2014

how to Update XAMPP in Windows 7 or others

To update XAMPP in Windows. Please follow these steps.
  1. Download the latest version of XAMPP
  2. Now backup your existing “htdocs” folder.
  3. Backup your existing “data” folder, which is inside the mysql folder.
  4. Over-right all the files of existing “xampp” folder with the latest version of “xampp”
  5. If you have installed the installer version of XAMPP then just download the latest installer version of XAMPP and just install the latest version on the same location so it overwrites the existing files.
  6. After overwriting all the files run “setup_xampp.bat“, which is inside the “xampp” folder.
  7. Copy all your sites folder back to “htdocs” folder.
  8. Copy your old “data” folder and paste it inside the “mysql” folder
  9. Now fire up Apache and MySQL
  10. Visit your sites.
  11. If you can visit you sites then its done. But sites that uses MySQL database might cause some problem if you used any other user name and password other than the default xampp password. In that case follow on.
  12. Visit “phpMyAdmin” from http://localhost/phpmyadmin
  13. Press the “Privileges” tab, here if you used “root” user with a password then change the passwords for bothroot at localhost and
  14. If you used a different user name and password all together then create the new user using your old details that you used on your previous XAMPP installation.
  15. Now you should be able to visit your sites that uses MySQL database. eg: Joomla, wordperss etc
  16. Remember if you change the root users passwords then phpMyAdmin will not be able to connect to theMySQL database until you change the phpMyAdmin configuration.
  17. To change phpMyAdmin configuration goto (using file explorer not your browser) “xampp/phpMyAdmin” and open “
  18. On line 21 of “” type the root users password. eg:$cfg['Servers'][$i]['password'] = ‘root_users_password‘;
  19. If you want then you can change the user name too, in that case you will have provide that users password.
If you have followed my instructions then you should have a functioning XAMPPP with no issues. If you do face any problem then please leave a comment and I will do my best to get back to you.

Wednesday, September 17, 2014

Yii CListView/TbListView - jquery are not working after pagination

Recently i faced an issue in yii/ajax pagination that running some javascript/jquery function in the randerpartial view.

let me explain the issue here

i have a view.php  and the _view.php for partial file.  there are some jquery function in randerpartial(_view.php) file which will work with each item ID. so i just add the JQuery codes in the partial(_view.php) file .

on the first page load , the jquery functions are works fine and when i go for the second page using yii pagination . those jquery functions are not working . even when i use fire-bug / inspect element to view the code. those jquery codes are not there in the second page .its appearing on first view only.

while reading some forums and yii notes , found that yii-jquery firing some additional jquery codes on the pagination which overwrite / disabled mine. those says afterAjaxUpdate  will help to fix the issue as its will force to fire my jquery on pagination.

here i found thise useful link
but i found another shortcut too.

just made 'afterAjaxUpdate'=>'',  on the CListView/TbListView . will solve the problem as its not gonna fire any ajax/jquery code on the pagination , so my jquery will work normally on pagination.

problem solved!!!

my view.php:
1:  $this->widget('bootstrap.widgets.TbListView', array(  
2:                                     //'type'=>'striped bordered condensed',  
3:                                     'dataProvider'=>$dataProvider,  
4:                                     'id'=>'Manage',  
5:                                     'template'=>'{summary}{sorter}{items}{pager}',  
6:                                     'summaryText' => 'Showing {start} - {end} of {count} Jobs',  
7:                                     'itemView'=>'_view',  // refers to the partial view named '_post'  
8:                                     //'ajaxUpdate'=>false,  
9:                                     'emptyText'=>'<i> Sorry, there are no items to display</i>',  
10:                                     //'htmlOptions' => array('style'=>'margin-top:-20px;'),   
11:                                     'afterAjaxUpdate'=>'',                           
12:                                     'sortableAttributes'=>array(  
13:                                          'title'=>'Title',  
14:                                          'created'=>'Date Posted',  
15:                                          'status'=>'Status',  
16:                                ),  
17:                           ));  

1:  <select class="w-select status_action" id="Status_Action<?php echo $data->ID; ?>">  
2:            <option value="">Select one...</option>  
3:  .  
4:  .  
5:  .  
6:  .  
7:      </select>  
8:      <label class="updatestatus_text">Would you like to:</label>  
9:  <script>  
10:       $('#Status_Action<?php echo $data->ID; ?>').bind('change', function () {  
11:          var url = $(this).val(); // get selected value  
12:            if (url) { // require a URL  
13:                 window.location = url; // redirect  
14:            }  
15:            return false;  
16:       });  
17:  </script>  

adding this line helped me alot


Tuesday, September 16, 2014

Yii Framework Video Tutorials

When i started to learn yii framework about 2 years ago , i kept search on YouTube and daily-motion about yii. there are alot of videos i found . most of them not in English language , as we have alot of yii experts in Spanish and Russian most of the yii videos are in Russian and Spanish . but i never give up, continue Google it. there i go . .Found these useful Yii Beginners Tutorials on YouTube. there are few latest videos are released in YouTube for Yii2 too....

also there is a fully professional yii training video in packtpub published by Chris Backhouse . i bought it from packtpub .. quite amazing and teaching you the real yii shortcuts and clean coding .

here we go with the youtube links to learn yii



Linkedin - video tutorials request

packtpub video

and there are several Yii groups and forums that supporting Yii network other than

here we go with those list of links

from Facebook Group

from Google Plus community

another great contrubutor Christoffer Niska

from a famous writer larry

bunch of yii extensions in gith-hub

just google is "yii framework github" - this will give you a list of demo istes, scripts , extensions those listed in github..

enjoy yii geeks !!!!!!!