Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

EJS elements not available to jquery?

$
0
0
I am new to CanJS and am having an issue accessing elements loaded via EJS tamplates.  I am wanting to see if there is a workaround to the issue.
In my scenario I can initially access the element if the controller is called on pageload, but if it is disposed and then reloaded due to some routing logic later, it appears that the return html is not available in the DOM when my code executes.
Using setTimeout just after element.html(frag) having it pause a second fixes the issue, but didn't know if there was a better way to handle as jQuery html method does not support deferred functionality from what I can tell...
I assume this is more of a jQuery/DOM issue, but thought someone on the forum may have a work around...

An example:

var viewModel = {
                    searchfield: self.field,
                    windowdefinition: self.field.LookupWindowDefinition
                }


 can.view(self.options.view, viewModel, function (frag) {
                  self.element.html(frag);
                  // below fails to locate the element if the controller was earlier disposed and being recreated.
                  $('some_element).doSomething();
}


Any help would be appreciated...

thanks,
Bobby

Viewing all articles
Browse latest Browse all 3491

Trending Articles