text-decoration problem in Firefox, jQuery and jqgrid

让人想犯罪 __ 提交于 2020-01-10 06:05:35

问题


I have issue wuth Firefox not displaying style "text-decoration: line-through".

I am using jqGrid for displaying list of medications. If medication is not active, it has to be crossed. In my afterInsertRow event I do this:

$('#' + rowid).css({ 'text-decoration': 'line-through', 'color': 'red' }) 

It works fine for IE and Chrome, but Firefox displays only red text without crossing line.

When I look into firebug output, I can see that <tr> element has style definition including text-decoration, but it is simply not displaying the way I need.


回答1:


If you modify your code to

$('#' + ids[1] + " > td").css(
    { 'text-decoration': 'line-through', 'color': 'red' });

if will works. If you use rownumbers: true and don't want the row number be strikethrough, you can use

$('#' + ids[1] + " > td:not(.jqgrid-rownum)").css(
    { 'text-decoration': 'line-through', 'color': 'red' });

One more small recommendation: use gridview: true to fill jqGrid more quickly. In this mode the whole table contain will be filled by jqGrid as a siring and will be inserted with one jQurey.append operation. The usage of afterInsertRow event break the rule, because every row will be inserted with a jQurey.append operation and then will be called afterInsertRow. So my recommendation: use gridview: true and don't use afterInsertRow. To make changes of css use loadComplete or gridComplete instead like:

jQuery('#list').jqGrid({
    //...
    loadComplete: function() {
        var ids = jQuery('#list').getDataIDs();
        for (var i = 0; i < ids.length; i++) {
            $('#' + ids[i] + ' > td:not(.jqgrid-rownum)').css(
                { 'text-decoration': 'line-through', 'color': 'red' });
        }
    }
    // ...
});


来源:https://stackoverflow.com/questions/3025305/text-decoration-problem-in-firefox-jquery-and-jqgrid

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