Reputation: 8548
I am storing a reference to an object I created, and calling .append() on i works fine, though if I try doing a style change it won't allow me...
The error I get is
Uncaught TypeError: Cannot set property 'display' of undefined
Any ideas?
//add this slide's wrapper to module
self.node = $("<div id='module_"+self.moduleId+"-slide_"+self.currentSlide+"' class='slide fade'></div>").appendTo("div#module_"+self.moduleId);
//add the contents of the slide to its wrapper div
self.node.append( self.slides[self.currentSlide-1].html )
//Hack to force webKit to repaint (to have style fade applied) before the show() event.
self.node.style.display='none';
Upvotes: 0
Views: 74
Reputation: 38193
This line gives you a reference to a jQuery object:
self.node = $("<div id='module_"+self.moduleId+"-slide_"+self.currentSlide+"' class='slide fade'></div>").appendTo("div#module_"+self.moduleId);
You are referencing the jQuery object, when it looks like you need the actual DOM element, which is accessed via
self.node[0]
So your code would then read:
self.node[0].style.display='none';
Upvotes: 1
Reputation: 12961
you probably want to do this:
self.node = $("<div id='module_"+self.moduleId+"-slide_"+self.currentSlide+"' class='slide fade'></div>").appendTo("div#module_"+self.moduleId);
self.node.append( self.slides[self.currentSlide-1].html );
self.node.hide();
//or
self.node.css("display", "none");
Upvotes: 1