Jquery Ui Encoding Nightmare
I want to be able to pass any string to the buttons text in JQuery UI. Suppose I have this string: Ajouter L'amie a la liste 'amies'  The only way to actually pass this text withou
Solution 1:
To be able to use htmlentities, you'll have to use the html method when inserting the strings into the buttons, as text will literally insert the text without doing encoding of entities :
registerhtml.dialog({
    modal: true,
    title: 'My Dialog Title',
    resizable: false,
    buttons: [
        {
            html: 'Ajouter L'amie a la liste "amies"',
            click: function(){
                // Do something important
                $(this).dialog('close');
            }
        },
        {
            html: 'Cancel',
            click: function() {
                $(this).dialog('close');
            }
        }
    ]
});
Solution 2:
Depending if you use ' or " for your string, escape all accournces of ' ör " in the string with a \
Example:
<!doctype html><html><head><metacharset="utf-8"><title>Demo</title><scriptsrc="jquery-1.8.2.min.js"></script><scriptsrc="jquery-ui-1.9.0.custom.min.js"></script><linkhref="jQueryUI_css/ui-lightness/jquery-ui-1.8.24.custom.css"rel="stylesheet" /><script>
            $(function(){
                //using ' to define a stringvar text = 'Ajouter L\'amie a la liste "amies"'
                $('div').text(text).button();
                //using " to define a stringvar text2 = "Ajouter L'amie a la liste \"amies\"";
                $('button').text(text).button();
            });
        </script></head><body><div></div><button></button></body></html>
Post a Comment for "Jquery Ui Encoding Nightmare"