vendredi 20 février 2015

Can't access combodate from JS function


I suspect that the problem I'm having is just a misunderstanding of JS scope or something.


I have moment.js and combodate.js linked and the following code works fine when run immediately after my form:



<script type="text/javascript">
$(function(){
$('#birthday').combodate();
});
</script>


But if I want to run it in a function (to clear the form, for instance):



var launchChildRegisterModal = function() {
//Do other stuff...
$('#birthday').combodate();
}


I get the error:



TypeError: $(...).combodate is not a function


Do I have to do something special to use it from within a function?





Aucun commentaire:

Enregistrer un commentaire