Delete elements playing with submit (firefox)

1 view
Skip to first unread message

johnwards

unread,
Oct 19, 2007, 10:31:26 AM10/19/07
to Web Forms 2.0 Implementation, jwa...@whiteoctober.co.uk
This has been driving me up the wall today and I am stuck.

Right the situation is the following...

I have a form which if I add an element. Then remove the element it
refuses to submit using javascript. Only in firefox!

The sample form is here. (It may take a little while to download as
all the js is in uncompressed format for debugging.)
http://technode.whiteoctober.co.uk/formtest.htm

To replicate the issue do the following:

Enter a value for "Title" and "Description".

Add a text element.

Delete that text element.

Press the preview button.

Nothing should happen.

Now add another text element.

The preview window will now open.

I have made sure its not the validation side of things by removing all
validation and the bug still happens. I have put it back in because it
works with every browser as expected except firefox.

Its very strange that its after a delete that it happens and then it
submits the next time you press a button to add a template. I stepped
through the code in firebug but can't see anything that would cause it
on delete....

please help as I have been at this for 6 hours now...

johnwards

unread,
Dec 4, 2007, 10:21:23 AM12/4/07
to Web Forms 2.0 Implementation
Well I spent about 2 days on this stripping the code down trying to
figure out what was going on.

Once I thought I had explored all the different avenues I grabbed the
other developers in the company and asked them to think about
something else to try. After a couple of "yup tried that..." One guy
said its not an event on the "delete button" bubbling then as its
removed from the DOM firefox getting its self confused.

Well its seems that it is. I was unable to confirm where exactly its
going wrong but I have changed the delete button into a link with an
onclick. The onlick does this:

<a id="remove[row]" onclick="newdelete(this)"><span>Delete</span></a>

function newdelete(del){
block = $wf2.getRepetitionBlock(del);
block.removeRepetitionBlock();
}

Hope you can figure out whats causing the issue.

Weston Ruter

unread,
Dec 4, 2007, 11:23:05 AM12/4/07
to webf...@googlegroups.com
Hi John, sorry you've been experiencing this difficult issue. I recommend against using $wf2.getRepetitionBlock since it will not work with native implementations such as Opera; use something like this instead:

function newdelete(del){
    var parent = del.parentNode;
    while(parent && parent.repetitionType != RepetitionElement.REPETITION_BLOCK)
        parent = parent.parentNode;
    if(parent)
        parent.removeRepetitionBlock();
}

I haven't had time to debug this issue. If you would, please file a new issue describing the problem and attach the stripped-down example code that you worked on. Thanks!
Reply all
Reply to author
Forward
0 new messages