Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option onClose #42

Open
Mickdark opened this issue May 11, 2012 · 2 comments
Open

Option onClose #42

Mickdark opened this issue May 11, 2012 · 2 comments

Comments

@Mickdark
Copy link

Hy!

  When a try to call the function "onClose" create before, not function, I try to do the same way the DatePicker, like that:

//DatePicker - This Function
$(this).datepicker('option','onClose', '');

//TimePicker - Its not Function !!
$(this).timepicker('option','onClose', '');

There is a way to do that?

@fgelinas
Copy link
Owner

Hi,
I am not sure exactly what you want to do but you should only be setting onClose to a function or "null". The timepicker will call your onClose function right before it actually closes.

There is an example of using the events on the timepicker page at http://fgelinas.com/code/timepicker/

If you want to change the onClose function you can set it like this :

$( '#timepicker_input' ).timepicker( 'option', 'onClose', 
    function() { 
        alert ('This is in the onClose callback function' ); 
    } 
);

or remove the callback like this :

$( '#timepicker_input' ).timepicker( 'option', 'onClose', null);

@Mickdark
Copy link
Author

Hi!! Thanks for the answer!!
I wanted to do that because there are 1 event that close the timepicker, if somebody click the "Esc", it escape of my function onClose and dont do somethings that I wanted!! I dont now write english very very well, beacause Iam from Brazil!!

Follow my code!

//Previne o cursor ficar no input apos teclar enter ou esc (executando as funcoes do onClose)
$(datas.add(temposDeTodos).add(temposAteTodos)).keyup(function(event){
if(event.which==13 || event.which==27){ // 13=Enter ou 27=Esc
if(event.which==27){ // Se teclar Esc
$(this).datepicker('option','onClose', ''); // Executa novamente a funcao onClose do DatePicker
if($(this).attr('id').indexOf('tempo')>-1) // Caso seja o tempo
$(this).val(''); // Remove o conteudo do input(nao possui funcao para posterior execucao da funcao)
}
$(this).blur(); //Nos dois casos, tiro o cursor do input
}

});

@Mickdark Mickdark reopened this May 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants