I've got a jQuery dialog box with a button to close it. The button has focus when the dialog box opens. The problem is that the focus is a dotted line around the button's text instead of a focus ring around the entire button. I'm using jQuery's smoothness theme.
I'm using the dialog in a WordPress plugin.
My code is:
$('#mydialog').dialog({
title: 'My Title',
position: [619,200],
resizable: false,
buttons: {"OK" : function(){$(this).dialog("close");}}
});
The problem may relate to the browser; the way each browser highlights the focused element differs.
Related
I am trying to do something similar to what this page is doing.
The only difference is that the jQuery UI dialog I use is modal.
I tried editing the script in the page to make the jQuery UI dialog modal.
$("#dialog-modal").dialog(
{
modal: true, // added this line to make dialog modal
width: 600,
height: 400,
open: function(event, ui)
{
var textarea = $('<textarea style="height: 276px;">');
$(textarea).redactor({
focus: true,
maxHeight: 300,
initCallback: function()
{
this.code.set('<p>Lorem...</p>');
}
});
}
});
I then clicked on the insert link button(the 3rd button from the right in the toolbar). This shows another jQuery UI modal dialog with a form.
I noticed that I cannot get the focus of the text fields. I cannot type anything into them.
The code works fine if I don't make the the first dialog modal.
Any idea how to circumvent this?
I ran into the same problem. This behavior is a result of jQuery UI handling focusin.dialog event on the document, and putting the focus back to the last jQuery UI dialog in the stack (using selector ".ui-dialog:visible:last"). I solved the problem by calling this code right after my modal dialog was created:
setTimeout(function() {
$(document).unbind("focusin.dialog");
}, 100);
I used setTimeout, because jQuery UI also uses setTimeout to bind this event. I was able to fix it thanks to this answer: jQuery UI Focus Stealing. I also tried upgrading to jQuery UI 1.11.4 but that does not solve the problem.
I am using dnnAlert in my DNN 7.02 website ( dnnAlert is a jQuery UI plugin for dnnAlert that is included in regular DNN install) in place of regular alert, but the problem is that when I click on OK button, the page automatically scrolls to the top, which is very annoying.
How can I prevent the automatic scrolling?
$.dnnAlert({
text: 'Copied code to clipboard',
dialogClass: 'dnnFormPopup',
title: 'Copy Successful',
modal:false
});
The OK button is rendered with following html.
<button class="dnnPrimaryAction" type="button">Ok</button>
I have spent a lot of time trying to get JQUI dialogs to work properly in DNN 7.
I expect the problem you are having is related to setting
modal: false
I have found that using a straight JQUI dialog works if the crucial element:
dialogClass: 'dnnFormPopup dnnClear'
is added.
JC
I have two pages .I am able to show page on clicking the button but i need to show same content as a dialog box on same screen without changing the screen. I need to show dialog box having same field in page .Here is my code in fiddle. on clicking the add button new page is open but i need the dialog box.
http://fiddle.jshell.net/ravi1989/nLJR7/
Are you looking for this?
$.mobile.changePage($("#UserSettingScreen"), {
transition: "slide",
reverse: false,
changeHash: false,
role: 'dialog' // you can use role: 'dialog' to open a dialog
});
Here is jsFiddle demo.
UPDATE
1) You can close a dialog programmatically by calling dialog('close') method like so
$("#case_dialog_cancel").on("click", function(){
$("#CaseInformationScreen").dialog('close');
});
Here is updated jsFiddle.
2) You can theme an overlay. Read more about overlayTHeme. If you for some reason want to get rid of the overlay completely or make it transparent - google for hakish ways. Here is one link Transparent jQuery mobile dialogs
I am using the splitview plugin of jQuery.mobile jQuery Mobile - Splitview . I am using jQuery.mobile popups as context menus which are fired on taphold event. Right now I am opening popus by
$("#myPopup").click();
where myPopup is popup defined in HTML.
In this way I can open popup, but I can not position the popup to the position of tap. Does anyone have an idea?
Something like
$( ".selector" ).popup( "open", {x:event.pageX, y: event.pageY} );
does not work because of splitview plugin. Without this plugin it works perfectly.
(and of coarse, I know, that taphold event does not contain information about position, that was just an example. I tried it also with pure numbers and it does not work either)
Well, my solution is not beautiful, but it works. In HTML file I defined new DIV and before opening context menu I position it.
$("#contextDiv").css({
position: "absolute",
top: contextMenuTapY,
left: contextMenuTapX
});
Then I open the context menu relatively to this DIV
HTML:
JS:
$("#aPopupElement").click();
I want to show a popup screen on my page using JQuery UI Dialog widget.
To implement this I have a <div class="popup-placeholder"> on my page. Actually there are more than one on the page (If this makes a difference to the solution)
On click of a button, I am initializing the dialog and 'open'ing it. The initialization of the popup is inside the action click because it is supposed to make an Ajax call to get the content of the popup. (I tried taking the initialization out of the click event, but that did not work $('div.popup-placeholder').dialog(); )
var popupContext = $('#' + contextControl.id + ' > .popup-placeholder');
popupContext.html(formHtml);
$(popupContext).dialog({
bgiframe: true,
modal: true,
autoOpen: false,
closeOnEscape: false,
dialogClass: '',
draggable: true,
position: 'center',
resizable: false,
width: 600
});
On click of the action button, the form shows and does what it is supposed to.
Now, I have a close link on the popup WHICH IS NOT A DIALOG BUTTON, but just another link with an event binded to it.
It does this...
$('#popup-placeholder-61').dialog('close');
where #popup-placeholder-61 is the same as $(popupContext)
The problem I am facing now is that, on close of the popup, the same action button does not show the popup again. The issues seems to be that the <div class="popup-placeholder"> has been removed from the mark-up.
I tried the solutions on the following page but did not help -
Jquery Dialog Close on StackOverflow
So, I need more help
After struggling a bit, i came up with a best solution. Please use below line instead of dialog('close')
$('#popup-placeholder-61').dialog("destroy");
This will allow div to retain its position
My issue has been resolved, but I will be looking into why my earlier approach did not work.
What I was doing earlier was that I had multiple place-holders with different IDs, and I was making only one of them the dialog. I used some Jquery selectors to select the appropriate div for the dialog box and had issues as described above.
The only change I did now is that I have a single div which acts as the placeholder. And that now works. It also initialized fine outside my event.
So, maybe it was something to do with my selectors? I will try more and if I find something will post it as a follow up.
Thanks.
Try taking the initialization code out of the click event it may be that by trying to rebind everything again it's failing to pop the dialog open with the second click ... I had a similar problem which I "resolved" by creating the the markup for the dialog every time the dialog was to be opened.
The ajax bit of your problem is not hold back for you to take the initialization out of the click event, just load your ajax content on the click event and show the dialog with dialog('open').
The main problem was that I was looking for the dialog div in the wrong place.
See this post for more details ...
Jquery Dialog - div disappears after initialization