I have this constructor:
var sendMessagePopup = Ext.create('Ext.window.Window', {
title: 'Closing Doodad issue',
id: 'sendMessagePopUpJS',
width: 550,
height: 435,
loader: {
url: "#Url.Action("SendMessagePopup", "Message")?subject=" + "#Model.Obj1.Model.Obj1Number - completed this" + "&messageBody=I will close this doodad.",
loadMask: true,
autoLoad: false,
scripts: true,
renderer: 'html'
},
autoScroll: true,
resizable: false,
layout: 'fit',
closable: true,
closeAction: 'hide',
modal: true,
header: true
});
I get this window to show by calling this:
<a class="btn c10 buttonsRowForPreviewFixedWidth" onclick=" sendMessagePopup.show();
sendCloseMessagePopup.loader.load(); ">Close Item</a>
This current works fine, but I want to re-use this for when a user would click on the opposite action : to open a doodad issue. I've put two constructors for different windows on the page. but that is causing issues with the second one that contains the "Open Issue" literals not working properly.
The second button:
<a class="btn c10 buttonsRowForPreviewFixedWidth" onclick="sendOpenMessagePopup.show();
sendOpenMessagePopup.loader.load(); ">Open Item</a>
How would I go about changing the title attribute, and some of the text in the loader when loading this window from a "Close this" or "Open This" button.
EDIT: I had a look at Extjs pass in parameters to window on show, but I cannot use the show().
If I understand you correctly you want to re-use one component on two different occasions. In this case I would suggest using a component definition.
So instead of Ext.create('Ext.window.Window', {...}) you should use
Ext.define('sendMessagePopUpJS',
{
extend : 'Ext.window.Window',
width: 550,
height: 435,
etc.
Then you can create a new window on each click, and pass it some options, like
Ext.create('sendMessagePopUpJS',
{
title: 'foo'
}).show();
Related
I have a page where I call a java script to open a popup. This pop up is defined as a Kendo().Window in common .js file for an application.
On the page I have a jQuery that opens a pop up om .Ajax success:
var dialog = $("#myWin").data("kendoWindow");
$("#dWin").html(result);
dialog.open();
And in a common .js file I define the window:
$("#myWin").kendoWindow({
visible: false,
modal: true,
//title: "Details Report",
open: function (e) { $("html, body").css("overflow", "hidden"); },
close: function (e) { $("html, body").css("overflow", ""); },
draggable: false,
width: 850,
height: 430,
position: {
top: 100,
left: 500
},
resizable: false
});
Before, I had this code on each page, where I was able to define its oww window with a title. Now, I moved it to a common file and need to set the specific title related to each page. I looked up in the inspect element window, that the title id is win_wnd_title and tried to set the title like that:
$('#win_wnd_title').val("Specific Title");
But that did not work.
What is the best way I can accomplish something like that?
Just figured out the answer:
$('#win_wnd_title').text("Specific Report");
I am trying to get a jquery ui dialog to open in a parent window from a child window. In other words, as the child can only have the dialog popup only with in its window's constraints, I would like to be able to use the contents of the dialog's popup in the constraints of the parent window.
I was trying to use a window.opener to tie in a link, but wasn't having much luck.
Here's the code that opens the window from a Backbone View HTML page:
popoutWindow = window.open("campaign/genericPopout.aspx", "search", "width=800, height=600, toolbar=0, status=0, menubar=0, scrollbars=1, resizable=1", true);
inside the genericPopout.apsx's call to a file that builds, with Backbone View, with this command,
new popupSearchView();
it calls the following Backbone View:
var popupSearchView = Backbone.View.extend({
events: {
"click #closeBtn" : "closePopupSerachView"
},
initialize: function() {
this.template = _.template("<div id='searchPopupView'>" +
"<div style='width: 100%; text-align: center;'>Hello World</div>" +
"<div style='text-align: center;'><input type='button' id='closeBtn' value='Close' /></div>" +
"</div>"
);
this.render();
},
render: function () {
formString = this.template();
$(formString).dialog({
autoOpen: true,
height:460,
width: 350,
title: "Search",
modal: false
})
return this;
},
closePopupSearchView: function () {
$(this).dialog("close");
}
});
It opens the popup dialog fine within the newly opened window, but it doesn't seem to work. In the parent window HTML, I have a div devoted to this dialog:
<div id="popupSearchViewDiv"></div>
and I tried setting the Backbone el to this div by this:
el: $("popupSearchViewDiv", window.opener.document)
yet this does not seem to work. Any thoughts on how I can accomplish this?
Thank You
I came up with a way to do this. I'm not sure how efficient it is, but it may be the only way.
In the opener window, I placed the code jquery-ui dialog:
function openSearchViewPopup() {
$("#popupSearchViewDiv").dialog({
autoOpen: true,
height:460,
width: 350,
title: "Search",
modal: false
}
With a predefined DIV in the index.aspx of:
<div id="popupSearchViewDiv"></div>
From the window opened from the index.aspx that holds the above function code, I call the function like this:
render: function () {
var htmlToWrite = this.template();
$(window.opener.docuemnt.getElementById("popupSearchViewDiv").append(htmlToWrite);
$window.opener.openSearchViewPopup();
}
This seems to allow the jquery-ui dialog popup to open in the window.opener window and to be used there.
I am trying to bring a Dialog Box using jQuery-UI where I am facing one issue.
Dialog box is opened in screen with its Tiltle and close button.However I am not able to close the dialog.I understand the issue is, the dialog opened is not recognized and hence the close button is not working.I am able to select elements in parent page which should not happen.
I done several researches in Google and could not find a solution for that.
Please help me to sort out this issue. I am pretty new into Java Scripts and jQuery.
The following are my codes.
Using jQuery UI - v 1.9.0.
HTML code
<div id="dialog">
<p>This is test Dialog Box Message !!</p>
</div>
Controller.js
There is a button in my page and inside of this button click event,I have
$("#dialog").dialog({
autoOpen: false,
title: "Test Tiltle",
height: 300,
width: 350,
modal: true,
show: 'fade',
hide: 'fade',
close : function() {
$(this).dialog( "close" );
}
});
$("#dialog").dialog( "open" );
You left of a "
http://jsfiddle.net/uDYcJ/1/
$("#dialog").dialog({
autoOpen: false,
title: "Test Tiltle",
height: 300,
width: 350,
modal: true,
show: 'fade',
hide: 'fade',
close : function() {
$(this).dialog( "close" );
}
});
$("#dialog").dialog( "open" );
You can see from the colour formatting in your code block that you're missing a closing double quotes in your title:
title: "Test Tiltle,
Just close up that string:
title: "Test Tiltle",
I am building an MVC 4 app with lots of cells in a table which the user will click for additional data about the contents of that cell, so I pop up a modal jQuery dialog. I don't claim to have done this correctly but I have an Ajax form that contains nothing but a hidden field to send off the id of the clicked cell contents to the controller.
#Html.Hidden("selectedStatusId")
Then on clicking I get the id and put it into that hidden:
$(".statusCell").click(function () {
var statusId = this.id;
document.getElementById("getStatusDataForm").selectedStatusId.value = statusId;
$("#getStatusDataForm").submit();
$("#StatusData").dialog("open");
});
The next to the last line is submitting the form which returns a partial to the empty div:
<div id="StatusData" title="Status Details" class="selectedStatusDetail" style="display: none"></div>
Then I configure my dialog:
$(function () {
$("#StatusData").dialog({
autoOpen: false,
modal: true,
resizable: false,
draggable: true,
width: 800,
show: {
effect: "fade",
duration: 100
},
hide: {
effect: "fade",
duration: 100
},
create: function (event, ui) {
// Center the dialog each time it re-opens
$(this).dialog('widget')
.css({ position: 'fixed' })
.position({ my: 'center', at: 'center', of: window, collision: 'fit' });
},
open: function (event, ui) {
// Remove the closing 'x' from the toolbar and replace it with the text 'Close'
$('.ui-dialog-titlebar-close')
.removeClass("ui-dialog-titlebar-close")
.html('<span style="float:right; margin-right: 10px; font-weight: normal;">Close</span>');
},
});
So the first time I click on one of the cells the dialog displays 107px below where it displays every time from then on. Other than that it works perfectly.
I have read about how you don't want to display before the dialog is loaded and I suspect that might be happening since the call to the db is async and I create the dialog before I know I get the data back. But this is the only way I have been able to get all of the rest to work.
Do I need to refactor the whole mess or is there a fix?
I use several jquery ui dialogs in my application to collect input from users and for CRUD operations. When in a page I need a dialog I do the following steps:
First I define the minimum markup and code necessary to initialize the dialog like this
<div id="dialogPanel" style="display:none" title=""></div>
and, when the DOM is ready,
$("#dialogPanel").dialog({
autoOpen: false, hide: 'slide', show: 'bounce', resizable: false,
position: 'center', stack: true, height: 'auto', width: 'auto',
modal: true, overlay: { opacity: 0.5, background: "white" }
});
Then I load content in the dialog when I need it using ajax calls, like this
<button id="addCustomer">Add Customer</button>
and this
$("#addCustomer").button().click(function(event) {
event.preventDefault();
loadDialog("/Customer/Create", "", "Add New Customer");
});
function loadDialog(action, id, title) {
$("#dialogPanel").dialog("option", "title", title);
if (id != "")
action = action + "/" + id;
$.ajax({
type: "get",
dataType: "html",
url: action,
data: {},
success: function(response) {
$("#dialogPanel").html('').html(response).dialog('open');
}
});
}
The ajax call returns a strong typed view that will show inside the dialog and even resize it dinamically. The strong typed view has some buttons that, in turns, does other ajax calls (for example to the controller action that validate and persist on the database). These calls usually returns back HTML code that will be added to the dialog DIV.
Now my question is: How do I close the dialog? I can do it by clicking the "X" button on top right corner of the dialog or by pressing the ESC key but I would like to do it as a consequence of the click to the button that is inside the strong typed view .
However I do not wish to use this kind of code
$("#dialogPanel").dialog('close');
inside a strong typed view that does not defines the #dialogPanel DIV in itself.
What could be a good solution?
Create a closeDialog function in the main form, and call that function from within the dialog. Then any other page that hosts the dialog also needs to define a "closeDialog" function.
Also, you could pass a delegate pointing to the closeDialog function to separate things further.