This is a migrated thread and some comments may be shown as answers.

[Solved] Modal Windows - Shared Model names

2 Answers 173 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Terry Burns-Dyson
Top achievements
Rank 1
Terry Burns-Dyson asked on 26 Oct 2010, 03:38 PM
I have multiple forms I need to display in windows on my page. Originally I was creating the windows and including them by rendering them out at the bottom of the page I needed them on. Unfortunately, I hit a snag. Several of the forms have fields with the exact same name. As I'm binding the forms to the model, I cannot provide unique names or I don't get the data posted. 

Now, I've moved them out to javascript and am creating the windows as and when I need them, destroying them after so that no form fields overlap. Unfortunately, if I remove the last server side renderaction of a window, I then can't create the windows. "create is undefined". 

So, three questions / problems;

How do I have multiple forms on the same page with the the same field names (they aren't the same model). ?

How do I create the windows purely in Javascript, not requiring any server side includes, I've tried getting the scripts in by including the relevant js files through the scriptmanager, but I still get the issue. 

If I can't do this, how do I load the contents in via iframes, I assume I would then be able to work with each as if it was a unique page.

To add to this, I have no available sample as my code is heavily dependent upon other source code. So, I'll try my best to provide a working idea of what I'm doing;

function createAndDestroyWindow() {
    var tmp = $.telerik.window.create({
        modal: false,
        resizable: false,
        draggable: false,
        visible: false
    });

    tmp.data('tWindow').destroy();

    return tmp;
}

I use this in order to stop the window partially rendering the first time I call it. When I show the windows, I attach the data and on the onclose, I destroy the window. This seems to in most cases stop me from having duplicate model ids, until I the one situation whereby I have two windows needing to be open.

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 26 Oct 2010, 03:45 PM
Hi Terry Burns-Dyson,

 Up to your questions:

  1. You cannot have multiple elements with the same ID. This is not valid HTML not to mention the other implications.
  2. The way to go is to manually include the required JavaScript files.
  3. Using iframes is a possible solution but is somewhat of an overkill.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Terry Burns-Dyson
Top achievements
Rank 1
answered on 26 Oct 2010, 06:29 PM
I understand that you can't have multiple elements on a page with the same ID. My question was more to, how do other developers get around this issue.

ModelA has fields;

int ThisPrimaryKey
int TestId
string Address

ModelB has fields
int MyPrimaryKey
int TestId
string Address

I have two windows that contain forms representing these two distinct model objects, I need them in two different places within the same screen. If I preload the windows, Html.RenderAction( "Window", "Controller1") / Controller2, then when I submit either of the windows the model won't get posted back to the controller because there are mutliple elements on the page with Id "Address" and id "TestId" etc. Do I name the objects, and deal with FormCollection? I understand there's a difficulty in what I'm asking, so really I'm after the best practice of handling this.
Tags
Window
Asked by
Terry Burns-Dyson
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Terry Burns-Dyson
Top achievements
Rank 1
Share this question
or