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

[Solved] Modal property not working on second open

12 Answers 410 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.
Mac
Top achievements
Rank 1
Mac asked on 12 Sep 2010, 06:45 PM
Hello,

I am using a JavaScript created MVC Extension Window and it is set with Modal equals true. This works great on the first call, however if the windows is closed and then it is opened again, the window is no longer modal.

Is there something missing from the code below?

Thanks,
Calvin
var windowElement = $.telerik.window.create({
    title: "Form",
    html: '',
    contentUrl: createFormAction,
    modal: true,
    resizable: true,
    draggable: true,
    onClose: function () {
        var window = $(this).remove();
    }
})
.data('tWindow').center().open();

12 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 14 Sep 2010, 11:07 AM
Hello Calvin,

Could you please open a support thread on the same matter and attach a simple project reproducing this issue?

Thus I will give all my best to find a quick solution of your requirements.

Kind regards,
Hristo Germanov
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
Accepted
Joan Vilariño
Top achievements
Rank 2
answered on 15 Sep 2010, 09:15 AM
Hi Calvin.

I was having this issue also, and found that if you "destroy" the window on close.. it works.. like this:

var windowElement = $.telerik.window.create({
    title: "Form",
    html: '',
    contentUrl: createFormAction,
    modal: true,
    resizable: true,
    draggable: true,
    onClose: function () { 
           e.preventDefault();
        windowElement.data('tWindow').destroy();
    }
})
.data('tWindow').center().open();

I hope it helps...

Cheers
0
Mac
Top achievements
Rank 1
answered on 15 Sep 2010, 10:27 AM
Hi Joan,

That did the trick perfectly!

I've attached a new snippet that I tested.

Thanks again!

Calvin

var windowElement = $.telerik.window.create({
    title: "Create Organization",
    html: '',
    contentUrl: createAction,
    modal: true,
    resizable: true,
    draggable: true,
    onClose: function (e) {
        e.preventDefault();
        windowElement.destroy();
    }
})
.data('tWindow').center().open();
0
Joan Vilariño
Top achievements
Rank 2
answered on 15 Sep 2010, 10:31 AM
Strange ... "destroy" didn't work for me if I didn't include the ".data('tWindow') part ... anyway, I'm glad it helped...

Cheers
0
Mac
Top achievements
Rank 1
answered on 15 Sep 2010, 10:45 AM
I agree, but what I think is happening here is that it basically does have tWindow, it's just built into windowElement.

I apologize ahead of time if you already know this part :)

Normally when referencing a Telerik Window through jQuery, you have to include the reference to the actual window object which is attached to the dom element in question ( http://api.jquery.com/data/ ).

However, in this case, if I'm correct, it is already referencing the window object that is stored in the data container when we do this:
var windowElement = $.telerik.window.create({






0
Joan Vilariño
Top achievements
Rank 2
answered on 15 Sep 2010, 11:03 AM
Yes you are right... the difference in my case is that I do the work in two sentences like this:

var windowElement = $.telerik.window.create({ 
    title: "Form", 
    html: '', 
    contentUrl: createFormAction, 
    modal: true, 
    resizable: true, 
    draggable: true, 
    onClose: function () { 
           e.preventDefault();
  
        windowElement.data('tWindow').destroy(); 
    
});
  
windowElement.data('tWindow').center().open();

That's why I need to reference data inthe onclose parameter...
0
Gaurav
Top achievements
Rank 1
answered on 20 Oct 2010, 12:22 PM
Hi,
I tried all the options given for destroying the object, but i am getting the following error.

"Cannot call method 'create' of undefined"

Can you pls help me out.

Regards,
Gaurav Garg
0
Joan Vilariño
Top achievements
Rank 2
answered on 05 Nov 2010, 11:41 AM
Are you sure you loaded "telerik.window.js" and it's dependant javascript files ? If the window is created at client, the ScriptRegistrar won't do the work for you ...

To be sure, add:

<script src=".... ... path to telerik js .../telerik.window.js' type='text/javascript'><script>
<script src=".... ... path to telerik js .../telerik.draganddrop.js' type='text/javascript'><script>

in your page BEFORE the call to $.window.telerik.create

I hope this will help you.. and sorry for the delay

Cheer!
0
sowmya
Top achievements
Rank 1
answered on 25 Jan 2011, 09:34 PM
Hi,
I am click of button i am need to open a telerik modal window, so I am trying to create a modal window in Jquery, using the below code. I am getting a jquery error - Webpage error details

Message: Object expected
Line: 230
Char: 17
Code: 0
URI: http://ModalWindow/telerik-2010.3.1110/telerik.window.js
var windowElement = $.telerik.window.create({
    title: "Create Organization",
    html: '',
    contentUrl: createAction,
    modal: true,
    resizable: true,
    draggable: true,
    onClose: function (e) {
        e.preventDefault();
        windowElement.destroy();
    }
})
.data('tWindow').center().open();

telerik.window.js is already referenced in a base page, but still i am getting an error saying object expected.
0
Craig Fisher
Top achievements
Rank 1
answered on 05 Feb 2011, 01:21 AM
I was having a similar problem - the second time I opened a Window the grid within that window wouldn't do any Ajax requests. Adding the destroy call in the onClose handler fixed this problem also. Thanks Joan!
0
shabeer
Top achievements
Rank 1
answered on 09 Mar 2011, 07:56 AM

Hi, what does the contentUrl contain?

Can i use like this:
contentUrl: '<%: Url.Action("Action", "Controller"%>'


Is there any other way I can load a partial view to the newly creating window..

0
Joseph
Top achievements
Rank 1
answered on 11 May 2012, 10:36 AM
It took me a lot of time to figure it out, but this looks awesome and it works perfectly

cheers :)
Tags
Window
Asked by
Mac
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Joan Vilariño
Top achievements
Rank 2
Mac
Top achievements
Rank 1
Gaurav
Top achievements
Rank 1
sowmya
Top achievements
Rank 1
Craig Fisher
Top achievements
Rank 1
shabeer
Top achievements
Rank 1
Joseph
Top achievements
Rank 1
Share this question
or