Skip to main content

Posts

Showing posts with the label jquery

Js/jQuery load alternative images synchronously?

You can find lot of links over Internet, how to load alternative images but most of them give examples of asynchronously loading not synchronously one. I was facing the same problem and it took around 4 hours for me to fix it and now it looks simple :) Scenario 1(simple): ======================= You have two images and want to show the 2nd one, in case 1st one is not valid. Use following image tag: <img src="'+src+'" onError="this.onerror=null;this.src=\'https://browshot.com/static/images/not-found.png\'" />;  Note: Please don't forget to add this.onerror=null otherwise browser may stuck in a loop. Scenario 1(typical): ======================= You have three images: 1. Show image1 if valid otherwise image2. 2. If image2 is also invalid show 3rd one. In this case we have to use above code as well as one more function for middle image. Not working -------------------- You can use following code in JS and looks like i...

JavaScript : Check browser is mobile?

Nowadays, we know that it’s mobile era, so each and every website is having it’s mobile version as well. Some websites will automatically redirect to mobile version when you will try to open it on any mobile device like iPhone, iPad, Android phones etc. So how to check using JavaScript whether the hit is from mobile device or non-mobile device.   You can use the following code for this. //Example <script type ="text/javascript"> // check for the moble site (function(a){is_mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi...

Steps to Implement Datepicker in CakePHP

1) Download Jquery UI library from http://jqueryui.com/download/ . In my case I have downloaded version 1.8.22 library. Extract downloaded zip folder.  2) Copy \js\jquery-ui- version .custom.min.js file to \app\webroot\js\jquery-ui- version .custom.min.js  If you have not included jquery main file then also copy \js\jquery- version .min.js file to \app\webroot\js\jquery- version .min.js  3) Copy   \css\ui-lightness\jquery-ui- version .custom.css file to \app\webroot\css\jquery-ui- version .custom.css  4) Copy all images from \css\ui-lightness\images\.. to \app\webroot\img\...    5) Open \app\webroot\css\jquery-ui- version .custom.css file and replace "images/" text(path) with "../img/" . 6) Open view file and include following two lines : I have mentioned my file names here. <?php echo $this->Html->css('jquery-ui-1.8.22.custom'); ?> <?php echo $this->Html->script('jquery-1.8.2.min'); ?>...