sandipanmandal / lwrte

Automatically exported from code.google.com/p/lwrte
0 stars 0 forks source link

enable_design_mode adds duplicate submit events #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open page with Lightweight Rich Text Editor control in a form
2. Toggle back and forth between views several times
3. Submit the form containing the lwRTE control

What is the expected output? What do you see instead?
Expected output: When the form is submitted the rich text data from lwRTE
is received for application consumption.
Instead: When the form is submitted multiple copies of the text from the
lwRTE control are posted.

What version of the product are you using? On what operating system?
lwRTE 1.1 currently testing with FF3 & Firebug

Please provide any additional information below.
It is easy to watch this occur when you use firebug to inspect the toggle
button.  You will see the changes to the HTML as you toggle back and forth
and when you submit the form you will see multiple input fields created.
One for each time you toggled into the visual editing mode.

Original issue reported on code.google.com by gd.wing...@gmail.com on 5 Mar 2009 at 7:52

GoogleCodeExporter commented 8 years ago
My current fix is to add a global variable:
    var isSubmitRteEventWiredUp = false;

and wrap the submit event wire up:
    if (isSubmitRteEventWiredUp == false) {
        $(self.iframe).parents('form').submit(
            function() { self.disable_design_mode(true); }
        );
        isSubmitRteEventWiredUp = true;
    }

This seems to work but I feel like it could be problematic.

Original comment by gd.wing...@gmail.com on 5 Mar 2009 at 8:00

GoogleCodeExporter commented 8 years ago
Still can't reproduce that bug :( There was 'duplicate problem' in the past, 
but i
was sure it was fixed. I'm going to release next version soon, try to test new
wersion. because right now i haven't that problem forages - at least i'm using 
it as
editor for my cms.

Original comment by plandem on 5 Mar 2009 at 10:45

GoogleCodeExporter commented 8 years ago
have you tried last version?

Original comment by plandem on 9 Mar 2009 at 3:03

GoogleCodeExporter commented 8 years ago
Ok, I've tested with the last version(1.2) and run with both jQuery 1.2.6 and 
1.3.2.
 I get the same results as before.

I have an aspx form with the lwRTE control.  If I don't include the code I 
posted in
comment 1 and I submit the form in visual editing mode an <input> control is 
created
for each time the editor was toggled back and forth.

This tells me that each time I toggle into the visual editor the function
enable_design_mode is being called and 'function() { 
self.disable_design_mode(true);'
is being added to the parent form submit event.  When the submit event is 
called it
runs through the 'self.disable_design_mode(true);' function for each time the 
editor
was toggled and creates an <input> control.  I can watch this happen in firebug 
and
have attached a screen shot.

I'm sure the code I'm using isn't the best solution but I have not been 
successful
trying to unbind the function from the submit event.  I believe if it is 
unbound when
the iframe_doc and iframe are removed at the end of the disable_design_mode 
function
then I wouldn't see this problem.

Thanks

Original comment by gd.wing...@gmail.com on 9 Mar 2009 at 9:28

Attachments:

GoogleCodeExporter commented 8 years ago
will try to dig that problem more :( still can't reproduce. Aspx - ASP.NET?

Original comment by plandem on 22 Mar 2009 at 11:28

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It has been a while but I still wanted you to know we've ported over to MVC and 
no
longer have this problem.  I'm going to guess that we had some web control that 
was
conflicting with this that when we rewrote it to use MVC it fixed the problem. 
Thanks for your help.

Original comment by gd.wing...@gmail.com on 1 Jun 2009 at 10:14

GoogleCodeExporter commented 8 years ago
I had the same problem (aspx - WinForm).
Solved it like this:

lwRTE.prototype.enable_design_mode = function() {
...
/* added */
    $(self.iframe).parents('form').unbind('submit');
/* original */
    $(self.iframe).parents('form').submit(
        function() { self.disable_design_mode(true); }
    );

...
}

Original comment by goran.he...@gmail.com on 20 Jun 2009 at 10:45

GoogleCodeExporter commented 8 years ago
Thanks, that worked for me for the most part.  I ended up just removing the 
ability
to toggle to html mode just because my users really don't need that 
functionality.

Unless it is already there and I'm just missing it, it would be nice to have the
ability to turn on and off the toggle button as an option to send to the 
plug-in when
I create it.

Original comment by gd.wing...@gmail.com on 11 Aug 2009 at 7:10

GoogleCodeExporter commented 8 years ago
I don't understand why you placed the code to listing to the submit event of 
the form
in the enable_design_mode method.

It would be better to place it in the constructor 
...
var lwRTE = function (textarea, options) {
..
}

and attach to the form this way:
...
$j(textarea).parents('form').first()
    .submit(function(){
...

Original comment by eamonnoc...@gmail.com on 24 May 2010 at 3:09