Search code examples
jquery-uijquery-ui-dialog

How can I include escaped characters in a jquery-ui dialog button?


I am trying to put the '¡' character (¡ in HTML) in one of my jQuery UI dialog buttons, but I can't figure out how this works. Here's my code:

registerhtml.dialog({
            modal: true,
            title: 'Registro en entreSartenes',
            resizable: false,
            buttons: [
                {
                    text: "¡Regístrate!",
                    click: function(){
                        $(this).dialog('close');
                        connect();
                    }
                },
                {
                    text: "No gracias",
                    click: function() {
                        $(this).dialog('close');
                    }
                }
            ]
        });

When the dialog pops up, I actually get "¡Regístrate!" in my button. I have also tried putting the unescaped text directly in the JS code ("¡Regístrate!") but I get weird characters when it gets displayed.

Does anyone know a solution for this?


Solution

  • Since you're using javascript and not HTML, you'll need to put the actual character, not the HTML entity. You'll be able to do it if you use the right encoding (like UTF-8, but any encoding that can represent the characters you need should work). Make sure your file is UTF-8 and that it is interpreted as such by the browser, by setting the encoding in the HTTP headers or the HTML meta elements.