How to show Russian text in jQuery dialog title

喜欢而已 提交于 2020-01-15 10:16:39

问题


How can I show Russian text in a jQuery dialog title? In my case, it shows just this - ???????

Does anybody know why?

Calls showAjaxDialog:

$('.ajaxDialog').click(function () {
    ShowAjaxDialog(true, 'Привет Мир', 330, 300, this.href);
    return false;
});

AjaxDialog code:

function ShowAjaxDialog(isModal, title, width, height, url) {   
    // show a spinner or something via css
    var dialog = $('<div style="display:none" class="ajaxDialogLoading"></div>').appendTo('body');

    // open the dialog
    dialog.dialog({
        // add a close listener to prevent adding multiple divs to the document
        close: function (event, ui) {
            // remove div with all data and events
            dialog.remove();
        },
        width: width,
        height:height,
        modal: isModal,
        title: title
    });

    // load remote content
    dialog.load(
        url,
        //{}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object
        function (responseText, textStatus, XMLHttpRequest) {
            // remove the loading class
            dialog.removeClass('ajaxDialogLoading');
        }
    );      
    //prevent the browser to follow the link
}

回答1:


Demo: http://jsfiddle.net/mhLc5/

Link: http://jqueryui.com/demos/dialog/

Code:

var $Dialog_div;

function fnOpenDialog() {
    $Dialog_div = $('<div id=\'ThisDialog\'>Hello</div>').prependTo('body');

    $Dialog_div = $('#ThisDialog').dialog({
        autoOpen: true,
        draggable: true,
        resizable: true,
        title: 'Dialog put russian text: Jquery скалы, скалы и StackOverflow',
        modal: true,
        stack: true,
        height: ($(window).height() * 0.95),
        width: ($(window).width() * 0.9),
        buttons: {
            'OK': function() {
                $Dialog_div.dialog('close');
            }    
        }
    });  
}

$('#ClickMe').click(fnOpenDialog);​

HTML:

<!-- This is more than likely an Adobe issue where it thinks it should be in the front
     all the time, no matter what. However, it is very annoying that you can't open
     a dialog over a PDF.-->

<body>
    <div id='ClickMe'>Click here!</div>
    <br/>
    <div></div>
    <br/>
</body>


来源:https://stackoverflow.com/questions/10396913/how-to-show-russian-text-in-jquery-dialog-title

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!