变音符号时不使用jQuery写在Web应用程序正确地呈现 [英] Diacritic Marks not render correctly in Web App when written with JQuery

查看:90
本文介绍了变音符号时不使用jQuery写在Web应用程序正确地呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC 4应用程序,我本地化。所有内置的资源配置和型号由于内容出现罚款,但在那里我本地化的书面内容的 JQuery的的编码错误的出现。下面是事情的渲染,注意红色盒子......他们应该是同一个词的例子。

I have an MVC 4 application that I'm localizing. All the built-in resourcing and Model attributed content is appearing fine, but where I localized content written for JQuery the encoding appears wrong. Here is an example of how things render, note the red boxes... they should be the same word.

这个问题似乎围绕着低于行code都围绕在我的查看

The problem appears to revolve around the below line of code in my View:

$("#FirstName").Watermark("@Resources.ApplicantGivenNameWatermark");

此的 JQuery的的实质上发生在一个串,然后当没有其他的值已经被提供其写入到输入。下面是code的抽象:

This JQuery essentially takes in a string and then writes it to the input when no other value has been supplied. Here is an abstract of that code:

$.fn.Watermark = function (text) {
    return this.each(
        function () {
            var input = $(this);
            map[map.length] = { text: text, obj: input };

            //Similar removal process lies here, this one also removes the style

            function insertMessage() {
                if (input.val().length == 0 || input.val() == text) {
                    input.val(text);
                    input.addClass("watermark");
                } else
                    input.removeClass("watermark")
            }

            input.focus(clearMessage);
            input.blur(insertMessage);
            input.change(insertMessage);

            insertMessage();
        }
    );
};

如何解决这将是AP preciated任何想法。作为一个方面说明,我已经能够在各种浏览器的可靠重新创建。

Any ideas on how to resolve this would be appreciated. As a side note, I've been able to reliably recreate this in a wide range of browsers.

推荐答案

尝试把这个在开始的功能:

Try to put this at the begin of the function:

text=$('<span>'+text+'</span>').text();

这篇关于变音符号时不使用jQuery写在Web应用程序正确地呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆