Author Topic: getMovie() does not find the movie after dynamic DOM modification  (Read 1744 times)

kongo09

  • Jr. Member
  • **
  • Posts: 43
This continues a post I did in the 1.x section of the forum - but since I use 2.x, I feel it is more appropriate here: http://megazine.mightypirates.de/forum/index.php/topic,467.msg3375.html#msg3375. Apologies for the cross-posting.

I'm dynamically modifying a page/DOM that contains a MegaZine3 2.x book/player. This involves taking out the player, updating it in the background (i.e. generating a new book) and then putting it back. Essentially, it is a full reload - something that apparently is not possible right now throught the interface.

The problem is, that the getMovie() function in megazine.js fails in Internet Explorer after the operation. Essentially, JavaScript throws an error of
Quote
Microsoft JScript runtime error: 'Megazine.getMovie()' is null or not an object
As a side-effect, this also kills some seam remoting I use on the page.

Following the suggestion found in the 1.x forum, I tried the
Quote
document.getElementById(MegaZine.moviename)
call instead. This eliminates the error, but calls to the object still don't show any effect.

Any ideas?
kongo09

kongo09

  • Jr. Member
  • **
  • Posts: 43
Re: getMovie() does not find the movie after dynamic DOM modification
« Reply #1 on: January 31, 2010, 02:51:20 pm »
Apologies, I made a typo in the script. So replacing the getMovie() function in megazine.js with
Code: (javascript)
  1. getMovie : function() { return document.getElementById([MegaZine.moviename]); },
makes the flipbook work, even after it has been removed from and reinserted into the DOM. Tested on IE 7 and FF 3.5.7
« Last Edit: January 31, 2010, 02:55:13 pm by kongo09 »

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: getMovie() does not find the movie after dynamic DOM modification
« Reply #2 on: February 01, 2010, 08:26:59 pm »
Works fine in all browsers I tested, so I guess I'll include that in future releases. One question, though: are the brackets in the function call really necessary? I.e. does it have to be
document.getElementById([MegaZine.moviename]);
or would
document.getElementById(MegaZine.moviename);
be fine, too?

I realize that both variants work (at least directly after loading the book, didn't try fiddling with the DOM, admittedly), but just curious why you use the "arrayed" one. Thanks :)
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.