我在插件脚本中有以下内容:
$("#menu")
.on( click , a[href^="/Test"] ,function(event){
event.preventDefault();
var href = $(this).attr( href );
alert(this);
// Load content
$( #content ).load(href, , function (responseText, textStatus, XMLHttpRequest) {
$(this).applyTemplateSetup().buildTableOfContent();
});
window.location.hash = # + href;
// Get nav link
var a = $( #menu a[href=" + href + "] );
if (a.length > 0) {
// Mark as current
$( #menu a ).removeClass( current );
a.addClass( current );
// Update breadcrumb
var breadcrumb = $( #breadcrumb ).empty();
while (a.length > 0) {
if (a.get(0).nodeName.toUpperCase() == A ) {
var target = a;
}
else {
var target = a.parent().find( a:first );
}
breadcrumb.prepend( <li><a href=" + target.attr( href ) + "> +
a.contents().filter(function () {
return this.nodeType == 3;
}).first().text()
+ </a></li> );
// Check if opened
var li = a.parent();
if (li.hasClass( closed )) {
li.removeClass( closed );
}
a = li.parent().parent().children( a, span );
}
}
});
I would like to also set the value of a link when the user clicks. I added this on my page but it seems like it does not get called. Is there a problem when I attach two of the same type of events to an element?
$("#menu")
.on( click , a[href^="/Test"] , function (event) {
event.preventDefault();
var href = $(this).attr( href );
var pk = href.substr(7, 4);
var rk = href.substr(12, 4);
var link = "/Admin/Testss/Edit?pk=" + pk + "&rk=" + rk;
$( #editLink ).data( href , link);
});