Pop up Form

Mar 31, 2011 at 10:54 AM
Hi,
In a pop up windows I have a table with the last column containing:
<td><a href="#" onclick="deleteRow('2')">Remove</a></td>
When this code is in place the OK button on the Pop up does not work. When I remove the above code the OK button closes the Pop up..
Any ideas?
Thanks in advance
Coordinator
Mar 31, 2011 at 12:26 PM

this usually could happen if you make some javascript errors

the ok button of the popup form does the ajaxSubmit, all the content of the popupform is inside a html form

Mar 31, 2011 at 12:57 PM

Thats what I thought, but the javascript works fine:

 

function deleteRow(id) {
                var row = document.getElementById(id);
                row.parentNode.removeChild(row);
                };
Coordinator
Mar 31, 2011 at 1:19 PM
try this:
function deleteRow(id) {
		alert(id);
                var row = document.getElementById(id);
                alert(row.innerHTML);
                row.parentNode.removeChild(row);
		alert('executed');
                };

see how far how you code is working
Mar 31, 2011 at 2:07 PM

I hit all the alerts:

 

alert 1: id (2)

alert 2: inner html (<TD>value</TD>..for example)

alert 3: executed

 

 

Coordinator
Mar 31, 2011 at 2:25 PM

try using jQuery instead of plain javascript and do e.PreventDefault() as first statement in your function

you can also try and reproduce the same thing in a very simple separate project, try to remove anything useless in order to reproduce this

Mar 31, 2011 at 5:48 PM
ok i found the problem....

 Basically I have a main page with a pop up form link ("New Order")

When a user click the "New Order" link the "New Order" pops up.

On the "New Order" pop up I have a pop up form link's ("CPU") ("Motherboard") ("Memory")

When a user clicks on for example "CPU" another form pops up with two of your very awesome drop down box (Box 1 - Company) (Box 2- CPU Type). When this pop up form is closed (User clicks OK) I return via jason the data I need to a success funcation called add:

 

 function Add(o) {
                var ia;
                var tr = document.getElementById('servicesTable').rows;
                var id = tr.length + 1
                var NewRow = "<tr id=\"" + id + "\"><td>" + o.CostCode + "</td><td>" + o.item+ "</td><td>" + o.des+ "</td><td>" + o.Cost + "</td><td><label onclick=\"deleteRow('"+id+"')\">Trash</label></td></tr>";
                //this portion appends the new record to the table
                $('#servicesTable tr:last').after(NewRow);
                //clear out the add form
                var serviceslist = [];
                var td = null;
                alert(NewRow);
                for (var i = 0; i < tr.length; ++i) 
                {
 		td = tr[i].cells;
                    for (var j = 0; j < td.length; ++j) 
{  
serviceslist.push(td[j].innerHTML);
} 
serviceslist.push('|');
 } 
document.getElementById("servicedata").value = serviceslist; 
}; 
This basically add the returen json data to the html table on the New Order pop up. Also it reads the html table for the <TD> cells and 
adds the value to an array which in turns updates a html.hidden("servicedata"), as soon as this html.hidden is updated i'm unable to close the new order pop up
Coordinator
Mar 31, 2011 at 6:50 PM

so you have a popupForm inside another PopupForm?  where are the MakePopupForm calls made ?

Mar 31, 2011 at 7:25 PM

MakePopupForm for New Order is in NewOrders/Index.aspx

MakePopupForm for CPU is in NewOrders/PopNewOrder.ascx

What I’m trying to do is create a shopping list….

I thought I could have the CPU pop up form return the values of the picked options from the drop down boxes to PopNewOrder, which it does….But I don’t know how to store the information so it can be accessed by the Controller for PopNewOrder and also add to it when new items are picked.

From: o [email removed]
Sent: 31 March 2011 18:51
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

so you have a popupForm inside another PopupForm? where are the MakePopupForm calls made ?

Coordinator
Mar 31, 2011 at 7:38 PM

I tried to do something similar:

grab the code from here: https://code.google.com/p/mvc-project-awesome/

run it and go to PopupFormDemo/index

you will see a button NewOrder (it's all in the PopupFormDemoController)

 

about storing stuff that would be processed by the controller:

any <input / <textarea that has name='something' and is inside a <form is accessible in the post action by doing Request["thename"] or theaction(string name1, int name2  or theaction(viemodel that has properties named like those inputs

Mar 31, 2011 at 11:11 PM

Will do.

I think the way the Add function is updating any control ( textarea, input or hidden) is stopping the popup window from closing:

document.getElementById("servicedata").value = serviceslist;

“serivcedata” could be textarea, input or hidden

From: o [email removed]
Sent: 31 March 2011 19:39
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

I tried to do something similar:

grab the code from here: https://code.google.com/p/mvc-project-awesome/

run it and go to PopupFormDemo/index

you will see a button NewOrder (it's all in the PopupFormDemoController)

about storing stuff that would be processed by the controller:

any <input / <textarea that has name='something' and is inside a <form is accessible in the post action by doing Request["thename"] or theaction(string name1, int name2 or theaction(viemodel that has properties named like those inputs

Apr 1, 2011 at 9:36 AM
Apr 1, 2011 at 2:37 PM

Hi,

Out of interest…

I have a popup form (form 1) with some validation for a drop down and a popup form link to another popup form (form 2), which also has validation for a drop down.

1. I click on the ‘OK’ button on form 1 and the validation message is show.

2. I then pick the options needed in form 1.

3. I then click on the link for form 2 and pick my option.

4. I then try to click on ‘OK’ on form 2, but it fails to close.

Is this because the model is still invalid from step 1? I have tried model.clear() in the form 2 controller but this has no effect.

From: o [email removed]
Sent: 31 March 2011 19:39
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

I tried to do something similar:

grab the code from here: https://code.google.com/p/mvc-project-awesome/

run it and go to PopupFormDemo/index

you will see a button NewOrder (it's all in the PopupFormDemoController)

about storing stuff that would be processed by the controller:

any <input / <textarea that has name='something' and is inside a <form is accessible in the post action by doing Request["thename"] or theaction(string name1, int name2 or theaction(viemodel that has properties named like those inputs

Coordinator
Apr 1, 2011 at 3:05 PM

if it's something related to validation you can debug and see if the ModelState is valid or if you hit the server at all

Coordinator
Apr 1, 2011 at 3:06 PM

also firebug can help you, it shows all the ajax requests and js errors

Apr 1, 2011 at 3:31 PM

The error:

“uncaught exception: [Exception... "'cannot call methods on dialog prior to initialization; attempted to call method 'close'' when calling method… “

Line 0

From: o [email removed]
Sent: 01 April 2011 15:06
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

also firebug can help you, it shows all the ajax requests and js errors

Apr 1, 2011 at 3:38 PM

I’ve resolved all my issues for the time being… thanks for your help

From: o [email removed]
Sent: 01 April 2011 15:06
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

also firebug can help you, it shows all the ajax requests and js errors

Coordinator
Apr 1, 2011 at 3:38 PM

probably you forgotten to call html.makepopupform before calling html.popupformaction

Apr 1, 2011 at 3:55 PM

Nope, just moved it to outside of popup form 1

From: o [email removed]
Sent: 01 April 2011 15:39
To: tom-garratt@hotmail.co.uk
Subject: Re: Pop up Form [awesome:251951]

From: o

probably you forgotten to call html.makepopupform before calling html.popupformaction