I am new to both Django and Javascript and am having trouble calling a user defined function from within a javascript function in Django template.
I have a javascript block as follows:
function EditDialog(pk) {
$.ajax({
url: "{% url 'populatereviewform' %}",
method: 'GET',
data: {
pk: pk
},
success: function(formHtml){
//Do something
alert("Success!")
},
dataType: 'html'
});
// this is my function that I would like to call
function MyFunc(e, offset) {
alert("Calling my function")
}
// Now I try to call this function from another function
("#dialog").submit(function(e)
{
this.MyFunc(e, "1");
return false;
});
}
My question is how can I call this nested function?
In the code above, I am creating a function called MyFunc which I am trying to call from the submit method. However, this comes back with this.MyFunc is not a function.