Hmm looks like this.href is the full url.
Is there a defined way to strip the host etc so it just leaves the path.
Ideally id just want to put a number in and handel the rest in the
function, ie for paging numbers in a datagrid list.
Dan Rossi wrote:
Hi here is the updated code
$(document).ready(function(){
$("a.nav").click(function(event) {
$("#content").load(this.href);
event.preventDefault();
});
$('a.view').livequery('click',function(event) {
alert('clicked');
return false;
});
});
a link inside the html being added to the layer via ajax is
<a class="view" href="/path">
Still doesnt work, or is able to recognise the class "view" on the a
link, to my knowledge when its added to the layer via ajax there is no
elements there, its all inside innerHTML.
Karl Swedberg wrote:
On Aug 22, 2007, at 5:41 AM, electroteque wrote:
Hi there, im having issues binding a click to links displayed after an
ajax call into a layer.
Here is what I have so far
$("#content a.view").click(function(event) {
alert(this.href);
return false;
});
<div id="content">
</div>
links in the ajax content is <a class="view" href="/path"> </a>
After the ajax call, the links are not within the div, using firebug,
everything is added into innerHTML, I cannot get to these at all, so
the click wont work.
I literally searched everywhere, the docs are failing to give such an
important example because im sure many use it, or need to use it this
way.
Any ideas ?
Did you look at the Frequently Asked Questions page?
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F
Your question looks like one that is frequently asked. :-)
Also, check out Brandon Aaron's Live Query plugin (featured on Ajaxian!)
http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com