From: SM on
Using the selection on the left panel, I load the results on the right
panel using jQuery Ajax. So far it's working really good:

....
$.ajax({
url: "includes/content.php",
data: "letter=" + letter.substr(letter.lastIndexOf("=") + 1),

success: function(data) {
$('#wrapper').removeClass("loading");
$('#content').html(data).fadeIn(400);
}
});
....



After the results are loaded on the right panel, I click on an <a> tag
that is suppose to trigger some javascript but doesn't:

inside php file:
<a class="btn_play">Play</a>


javasscript to trigger:
$('a[class=btn_play]').click(function(event) {
event.preventDefault();

// get the A tag ref
var file = $(this).attr('href');

alert(file);
});

The same <a> tag also exists on the left panel and triggers correctly.
But, on the right panel, it doesn't trigger at all! I believe it's
because it doesn't see the javascript.

I'm sure this is come out already, but i can't find the solution.

Any hints?

Thanks
Marco
From: David Mark on
On Jun 11, 1:01 am, SM <servandomont...(a)gmail.com> wrote:
> Using the selection on the left panel, I load the results on the right
> panel using jQuery Ajax. So far it's working really good:
>
> ...
> $.ajax({
>    url: "includes/content.php",
>    data: "letter=" + letter.substr(letter.lastIndexOf("=") + 1),
>
>    success: function(data) {
>       $('#wrapper').removeClass("loading");
>       $('#content').html(data).fadeIn(400);
>    }});
>
> ...
>
> After the results are loaded on the right panel, I click on an <a> tag
> that is suppose to trigger some javascript but doesn't:
>
> inside php file:
> <a class="btn_play">Play</a>
>
> javasscript to trigger:
> $('a[class=btn_play]').click(function(event) {
>    event.preventDefault();
>
>    // get the A tag ref
>    var file = $(this).attr('href');
>
>    alert(file);
>
> });
>
> The same <a> tag also exists on the left panel and triggers correctly.
> But, on the right panel, it doesn't trigger at all! I believe it's
> because it doesn't see the javascript.
>
> I'm sure this is come out already, but i can't find the solution.
>
> Any hints?
>

Yes. Stop using jQuery. Then you will find that you have to learn (a
lot) before you can script browsers. I know you don't want to hear
that, but it's reality. There are no magic scripts that can turn you
into a JS programmer overnight. This is particularly true of scripts
written by overconfident neophytes (e.g. jQuery).
From: SAM on
Le 6/11/10 7:01 AM, SM a �crit :
> Using the selection on the left panel, I load the results on the right
> panel using jQuery Ajax. So far it's working really good:
>
> ...
> $.ajax({
> url: "includes/content.php",
> data: "letter=" + letter.substr(letter.lastIndexOf("=") + 1),
>
> success: function(data) {
> $('#wrapper').removeClass("loading");
> $('#content').html(data).fadeIn(400);
> }
> });
> ...
>
>
>
> After the results are loaded on the right panel, I click on an <a> tag
> that is suppose to trigger some javascript but doesn't:
>
> inside php file:
> <a class="btn_play">Play</a>
>
>
> javasscript to trigger:
> $('a[class=btn_play]').click(function(event) {
> event.preventDefault();
>
> // get the A tag ref
> var file = $(this).attr('href');
>
> alert(file);
> });

I don't know at all jquery ...

try in address bar
javascript:$('a[class=btn_play]').style.color='red';alert($('a[class=btn_play]').href)

if jquery finds the link it will be in red
if the link has an href you'll get a message with this href
and, if not, I hope you'll get 'undefined'

if no link(s) found --> nothing firing or error

> The same <a> tag also exists on the left panel and triggers correctly.
> But, on the right panel, it doesn't trigger at all! I believe it's
> because it doesn't see the javascript.

As that link on has no href, what do you expect to get ?
Then ... how do you reach the one or the other using :
$('a[class=btn_play]')
does that return a collection of all A with class btn_play ?
if yes, how do you catch one of them ?


> I'm sure this is come out already, but i can't find the solution.

function sayMe () {
if(this.href) alert(this.href);
else alert('no href !');
return false;
}
function triggerPlays() {
var play_btns = $('a[class=btn_play]'), n = play_btns.length;
if(n && n.length>0)
while(n--) play_btns[n].onclick = sayMe;
else play_btns.onclick = sayMe;
}

--
sm
From: SM on
On Jun 11, 6:09 am, David Mark <dmark.cins...(a)gmail.com> wrote:
> On Jun 11, 1:01 am, SM <servandomont...(a)gmail.com> wrote:
>
>
>
> > Using the selection on the left panel, I load the results on the right
> > panel using jQuery Ajax. So far it's working really good:
>
> > ...
> > $.ajax({
> >    url: "includes/content.php",
> >    data: "letter=" + letter.substr(letter.lastIndexOf("=") + 1),
>
> >    success: function(data) {
> >       $('#wrapper').removeClass("loading");
> >       $('#content').html(data).fadeIn(400);
> >    }});
>
> > ...
>
> > After the results are loaded on the right panel, I click on an <a> tag
> > that is suppose to trigger some javascript but doesn't:
>
> > inside php file:
> > <a class="btn_play">Play</a>
>
> > javasscript to trigger:
> > $('a[class=btn_play]').click(function(event) {
> >    event.preventDefault();
>
> >    // get the A tag ref
> >    var file = $(this).attr('href');
>
> >    alert(file);
>
> > });
>
> > The same <a> tag also exists on the left panel and triggers correctly.
> > But, on the right panel, it doesn't trigger at all! I believe it's
> > because it doesn't see the javascript.
>
> > I'm sure this is come out already, but i can't find the solution.
>
> > Any hints?
>
> Yes.  Stop using jQuery.  Then you will find that you have to learn (a
> lot) before you can script browsers.  I know you don't want to hear
> that, but it's reality.  There are no magic scripts that can turn you
> into a JS programmer overnight.  This is particularly true of scripts
> written by overconfident neophytes (e.g. jQuery).

My mistake... wrong forum to write this post.
From: SM on
On Jun 11, 6:40 am, SAM <stephanemoriaux.NoAd...(a)wanadoo.fr.invalid>
wrote:
> Le 6/11/10 7:01 AM, SM a écrit :
>
>
>
> > Using the selection on the left panel, I load the results on the right
> > panel using jQuery Ajax. So far it's working really good:
>
> > ...
> > $.ajax({
> >    url: "includes/content.php",
> >    data: "letter=" + letter.substr(letter.lastIndexOf("=") + 1),
>
> >    success: function(data) {
> >       $('#wrapper').removeClass("loading");
> >       $('#content').html(data).fadeIn(400);
> >    }
> > });
> > ...
>
> > After the results are loaded on the right panel, I click on an <a> tag
> > that is suppose to trigger some javascript but doesn't:
>
> > inside php file:
> > <a class="btn_play">Play</a>
>
> > javasscript to trigger:
> > $('a[class=btn_play]').click(function(event) {
> >    event.preventDefault();
>
> >    // get the A tag ref
> >    var file = $(this).attr('href');
>
> >    alert(file);
> > });
>
> I don't know at all jquery ...
>
> try in address bar
> javascript:$('a[class=btn_play]').style.color='red';alert($('a[class=btn_play]').href)
>
> if jquery finds the link it will be in red
> if the link has an href you'll get a message with this href
> and, if not, I hope you'll get 'undefined'
>
> if no link(s) found --> nothing firing or error
>
> > The same <a> tag also exists on the left panel and triggers correctly.
> > But, on the right panel, it doesn't trigger at all! I believe it's
> > because it doesn't see the javascript.
>
> As that link on has no href, what do you expect to get ?
> Then ... how do you reach the one or the other using :
>     $('a[class=btn_play]')
> does that return a collection of all A with class btn_play ?
> if yes, how do you catch one of them ?
>
> > I'm sure this is come out already, but i can't find the solution.
>
> function sayMe () {
> if(this.href) alert(this.href);
> else alert('no href !');
> return false;}
>
> function triggerPlays() {
> var play_btns = $('a[class=btn_play]'), n = play_btns.length;
> if(n && n.length>0)
> while(n--) play_btns[n].onclick = sayMe;
> else play_btns.onclick = sayMe;
>
> }
>
> --
> sm

it works! ...