0

How to open list item (or folder) when user click on item row (not on linktitlenomenu column)? By default sharepoint select this item and I need select items by clicking on checkbox only and open item otherwise. I see many different jQuery scripts, but I find only how to get link on item with jQuery:

$(document).ready(function () {
    $('.ms-itmhover').each(
        function () {
            var a = $(this).find("td div[Field=LinkFilename] a")
            alert(a.attr('href'));
        }
    );

});

But I dont't know how to paste this url in row onclick handler.

4

2 回答 2

0

请检查以下代码,它可能会对您有所帮助。

 $(document).ready(function () {
    $(".ms-itmhover").each(function () {
        $(this).attr("href", $(this).find('td div[field="LinkFilename"] a').attr("href"));
    });

});
于 2013-07-04T13:16:59.560 回答
0

我建议不要这样做,但如果你真的想这样做,我建议使用dblclick而不是模糊默认的单击行为。

所以在你的$(document).ready或 JSLink 中放:

(function () {
    "use strict";
    var rows = window.document.getElementsByClassName('ms-itmhover'),
        len = rows.length,
        i, 
        setLinkOnRow = function (row) {
            var link = row.querySelector('td div[field^=Link] a'),
                href = link.getAttribute('href');
            row.ondblclick=function () {
                window.location.href = href;
            };
        };

    for(i = 0; i < len; i += 1) {
        setLinkOnRow(rows[i]);
    }    
}());

或者,如果您有 jQuery 供您使用:

(function ($) {
    "use strict";
    $('.ms-itmhover').each(function () {
        var $this = $(this),
            href = $this.find('td div[field^=Link] a').attr('href');
        $this.dblclick(function () { 
            window.location.href = href;
        });
    });
}(jQuery));
于 2016-03-16T08:54:42.203 回答