문제

I have a custom view helper in app/view/helper folder. The code for add text field is - in my code: $this->view->formText('date'); But instead of text field i want to add jquery datepicker like this: $this->view->datePicker('date');

But this does not work. Please help. Regards

도움이 되었습니까?

해결책

In principle, you do not need a view helper for this.

On the client side, just attach the jQuery datapicker to your element. How you target that element with a client-side selector is dependent upon the DOM hooks you have available in your page/form, but as an example, assuming a form with id myForm and an input field with name myDate that you would like to function as a datepicker, you could simply use:

function($){
    $(document).ready(function(){
        $('#myForm input[name="myDate"]').datePicker({
            // datepicker options here
        });
    });
}(jQuery);

Of course, this presumes that jQuery is loaded when this runs and that the datepicker plugin is loaded by the time the ready event fires on the document object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top