0

I've got this code to generate my datepicker:

<script>
        $(function() {
            $(".datepicker").datepicker({
                showOn : 'button',
                buttonImage : '../resources/images/calendar.png',
                buttonImageOnly : true,
                buttonText : 'Pick a date',
                onSelect : function() {
                }
            });
        });
    </script>

Every time there is a postback, I loose all my calendars.

I am working with JAVA and not .net. How can I do to resolve it?

Thanks.

2 Answers2

0

Try to create an object literal that contains the extensions as below, more you can find on Proper way to add a callback to jQuery DatePicker

(function($){
    var datepickerExtensions = {
        _oldAdjustDate: $.datepicker._adjustDate,
        _adjustDate: function(id, offset, period) { 
            var target = $(id);
            var inst = this._getInst(target[0]);
            var afterAdjustDate = this._get(inst, 'afterAdjustDate');
            this._oldAdjustDate(id, offset, period);
            if(afterAdjustDate && typeof afterAdjustDate === 'function'){
                afterAdjustDate(id, offset, period);
            }
        }
    }
    $.extend($.datepicker, datepickerExtensions);
})(jQuery);
Community
  • 1
  • 1
Disha
  • 392
  • 2
  • 7
  • oh ok, what error you are getting ? try **function pageLoad() { }** – Disha Jan 29 '15 at 11:49
  • There is no error... I put an alert in the script. It's called when I first load my page, but it's not when it's loaded with postbacks. –  Jan 29 '15 at 12:21
  • It's just small parts of my page that are reloaded, and not the entire page. I don't how to say to relaod the javascript code every time there is a postback. –  Jan 29 '15 at 13:04
0

I finally resolved to use this workaround; I changed my code like this:

<f:ajax execute="@form" render="@all">

Instead of:

<f:ajax execute="@form" render="@form">

This way, all the page is loaded.