jQuery Address plugin - How to get link clicked on in $.address.change()
I am trying to use the Address plugin from http://www.asual.com/jquery/address/ and I really need to be able to access the link or object that was clicked on that triggers the $.address.change function.
So basically, I have a link that looks like this:
<a href="#" class="active" rel="address:/show-my-activity">Activity</a>
And then I have the $.address.change function that looks like this:
<script language="javascript">
$.address.internalChange(function (e) {
// this is where I need to get the obj of what was clicked to trigger it
// find out what the e.value is, and do the ajax needed
});
</script>
I have already looped through all the properties of "e" but I can't find anything that references me back to the object that was clicked. Here is what comes back from the "e" variable...
undefinedtype value :change
time开发者_Go百科Stamp value :1317227369056
jQuery1317227368799 value :true
value value :/show-my-activity
path value :/show-my-activity
pathNames value :show-my-activity
parameterNames value :
parameters value :[object Object]
queryString value :
result value :undefined
target value :[object Object]
currentTarget value :[object Object]
handler value :function (e) {
var str;
var obj = e;
for (prop in obj) {
str += prop + " value :" + obj[prop] + "\n";
}
alert(str);
if (e.value === "/showMyActivity") {
}
}
data value :undefined
handleObj value :[object Object]
preventDefault value :function () {
this.isDefaultPrevented = Z;
var a = this.originalEvent;
if (a) {
a.preventDefault && a.preventDefault();
a.returnValue = false;
}
}
stopPropagation value :function () {
this.isPropagationStopped = Z;
var a = this.originalEvent;
if (a) {
a.stopPropagation && a.stopPropagation();
a.cancelBubble = true;
}
}
stopImmediatePropagation value :function () {
this.isImmediatePropagationStopped = Z;
this.stopPropagation();
}
isDefaultPrevented value :function Y() {
return false;
}
isPropagationStopped value :function Y() {
return false;
}
isImmediatePropagationStopped value :function Y() {
return false;
}
Any help would be greatly appreciated.
Looking at the documentation here http://www.asual.com/jquery/address/docs/
You can do this in your link's click event.
$('a').click(function() {
$.address.value($(this).attr('href'));
});
Then grab it with event.value
.
Edit: I updated the above solution with what I think might be helpful. Alternatively you can have a global variable that you assign your object to within its click event. Then you can use that variable within your other function.
精彩评论