Hi guys,
I have a controller loading JSON from an AJAX call which renders the EJS:
- var self = this;
-
- this.element.html( "//mws/student_dashboard/views/init.ejs",
- ajaxCall,
- function(result){
- // initialize scrollable
- $(".scrollable").scrollable();
- $('.next').bind('click', self.loadWritingActivity);
The problem I am having is that 1: straight after the html() call the controller does not have access to the newly created HTML. Therefore I am calling the result function. (I thought .html() was asynchronous)
I then need to bind the click on the new HTML (.next) to my function, the controller doesn't automatically pick it up even though the HTML is added to its element.
And finally when the self.loadWritingActivity function is clicked :
$('.next').bind('click', self.loadWritingActivity);
I can't reference the controller. I'm sure this is not how its supposed to be done. I belive the controller is supposed to have access to the elements generated on its view.
Can someone tell me where I am going wrong or how the rendering of EJS on a view/controller is supposed to be done?
Thanks is Advance
Ronan