thanks a lot for your patience and all these useful hints ! :) > There are several things that bother me about this code. The example, > by the way, does not run properly in IE8 (nor, I expect in earlier > versions.)
I'm working on a standalone C++ app. The Frontend/UI is the Gecko-Engine that is embedded in the backend written in C++. All what a webserver does shall later be done by the C++ backend. Therefore my web code hast just to be compliant with Firefox/Gecko. > ... simpler code work for you?: > > $(function() { > $("#MyDiv").html(data_at_startup).click(function() { > // Simulation of an AJAX-call > $(this).html(data_out_of_an_AJAX_call); > }); > }); Yes. The show( AJAX_data ) function helps to substitute the total content of "#MyDiv". The total substitution of all present <p>'s ( with the old one + the new one) in #MyDiv using show() seemed to be the most easiest way (1) not only showing the (added) new paragraph, but also (provide) ALL <p>'s with the click handler. > var myDivObject = { > show: function(txt) { > $("#MyDiv").html(txt).click( function() { > this.show( data_out_of_an_AJAX_call ); > }); > }, > hide: function() { /* ... */}, > otherVal: 17, // comma-separated list of members... > } I have to take some lessons in Javascript OOP > But even here, there is still something strange. On each click of the > div, you're binding another event handler to do the same job. that's the CENTER OF MY TROUBLE. I did speak about the reason for using the show() function above. But maybe I can get your patience for one more special example that desribes my intention and trouble more precisely: Let's assume I work on a web site that should display the paragraphs of a book. The book has chapters and each chapter has <p>s. I start displaying the first <p> (of the first chapter). When read by the user he clicks on the <p> and the next paragraph will shown. $("#MyDiv").append(next_pragraph_from_AJAX_call).click( function() { get_next_paragraph_via_AJAX } I can go on this way until the last <p> of the current chapter is added/shown. Now I should start with the first <p> of the second chapter. Therefore I have to delete all <p>'s (of chapter 1) and show the first <p> of chapter 2. This is what my show()-function should do (that bothers you [and me too]): replace all current shown <p>'s and RE-START with one <p> - the first one of chapter 2. Do you have any hint how to do it better ? sincerely fran -- View this message in context: http://old.nabble.com/jQuery-%2B-OOP-%2B-AJAX-tp26945051s27240p26952980.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.