1

SharePoint リストから駆動されるナビゲーション バーに取り組んでいます。.hover私のイベントを除いて、すべてが期待どおりに機能しています。

編集:コード行を次のように変更しました:

$('table').hover(function () { alert(this.id); });

ヘッダー タグにカーソルを合わせるたびに、警告メッセージが空白になることに気付きました。これは、IDを返すことさえしていないと私に信じさせます。ただし、親要素の ID が返されます ( <table>) .....私は愚かなことをしなければなりません。

私がこれを持っているとき、それは動作します:

$(document).hover(function () { alert(); });

しかし、私がこれを持っているとき、何も起こりません:

$("#Header0").hover(function () { alert(); });

これが SharePoint では機能しないのに、通常の Web アプリケーションを実行するだけで機能する理由について何か考えはありますか?

ここにすべての私のコードがあります:

    ///////////////////////////////////////////////////////////////////////////////////////////    //////////////////////////////////////////
////////////////////////////////////////EVERYTHING BELOW THIS LINE IS GOOD TO    GO/////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////    //////////////////////////////////////////
//Print Headers to Screen. This will drive the core functionalty of the navpart
var siteUrl = '/sites/dev';
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
theCounter = 0;
var Headers = new Array();
var getCurrentElementId = null;
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('myList');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where>");
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),  Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    theCounter += 1;
    Headers[theCounter - 1] = oListItem.get_item('Title');
}
var HeaderDisplay = _.uniq(Headers);
for (var i = 0; i <= HeaderDisplay.length - 1; i++) {
    $('#TableElement').append("<th id=Header" + i + ">" + HeaderDisplay[i] + "::::::" +  "</th>");
}
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

    ///////////////////////////////////////////////////////////////////////////////////////////    //////////////////////////////////////////
 ////////////////////////////////////////EVERYTHING ABOVE THIS LINE IS GOOD TO     GO/////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////    //////////////////////////////////////////


// You got the headers to print as expected. Right now you need to figure out how to get the current ID
// that the mouse is over. Try looking at another project you did where the mouse goes into the table header
// and the outline expands.


$("#Header0").hover(function () { alert(); });



//This should be the universal onmouseover event that will expose only links
//and values relavent to the selected header.

//$(document).ready(function onPageLoad() {
//    $().SPServices({
//        operation: "GetListItems",
//        async: false,
//        listName: "myList",
//        CAMLQuery: "<Query><Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where></Query>",
//        completefunc: function completeFunction(xData, Status) {
//            $(xData.responseXML).SPFilterNode("z:row").each(function () {
//                var Headers = "<th>" + $(this).attr("ows_Title") + "</th>";
//                $("#TableElement").append(Headers);
//            }); 
//        }
//    });
//});
4

1 に答える 1

1

このようなことをしてみてください...

$('#TableElement').hover(function () {
$('#Header0').hover(function () {
    $('#Header2').append("<li>" + this.id + "</li>");
});
});

jQueryがIDを「見つけられなかった」ため、これは機能していないと思われます。親の内部に入ると、それを取得する必要があります。

于 2013-10-09T02:02:13.957 に答える