I have a userscript (for Greasemonkey) where I use a jQuery UI dialog. The problem is that the close button appears empty.
My code was like this:
// ==UserScript==
// @name test
// @grant GM_addStyle
// @grant GM_getResourceText
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @require http://code.jquery.com/ui/1.11.4/jquery-ui.min.js
// @resource source_2 http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css
// ==/UserScript==
var src2 = GM_getResourceText ("source_2");
GM_addStyle (src2);
...
$(function() {
$( "#dialog" ).dialog({
title: 'My dialog'
});
});
In order to get the (full) jQueryUI theme's URL so that I may include it as a @resource
in my script,
(i.e. visit this page and select Smoothness
theme on bottom of the page)
it just prompts to download a whole .zip file - which I can't use in my userscript.
Based on the replies on this question jQuery UI Dialog - missing close icon what I've I've tried so far without success:
- loading
bootstrap
, and in fact loading it beforejquery-ui-min
that editing/adding this code into:
// ==UserScript==
// @name test
// @grant GM_addStyle
// @grant GM_getResourceText
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @resource source_1 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css
// @require http://code.jquery.com/ui/1.11.4/jquery-ui.min.js
// @resource source_2 http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css
// ==/UserScript==
var src1 = GM_getResourceText ("source_1");
GM_addStyle (src1);
var src2 = GM_getResourceText ("source_2");
GM_addStyle (src2);
...
$(function() {
$( "#dialog" ).dialog({
title: 'My dialog'
});
});
and
via some dom manipulation on the Dialog Open event:
that is, adding this extra code in the end:$(function() { // or omitting this line (and the last one) $("#dialog").dialog({ open: function() { $(this).closest(".ui-dialog") .find(".ui-dialog-titlebar-close") .removeClass("ui-dialog-titlebar-close") .html("<span class='ui-button-icon-primary ui-icon ui-icon-closethick'></span>"); } }); });
How to fix this?