[jQuery] Re: Can I "access" and change content loaded dynamically after jQuery.js?

2008-12-22 Thread suntrop

Ryura thanks for the link. I'll try it although I want to learn and
know how to deal without a plugin :)

Ricardo, this looks like it does what I want :) Let's say I want the
content (loaded via the load method) hide/show or catch some clicks
inside it. Then I have to put all the code for all pages I'll load
inside the callback function?

$("#content").load(loadLink, function(){
   hideLoader();
   // Hide DIV1
   // click this and make that

   // some code for page 1

   // code for page 2,3 …

   // open new window by clicking on …
   // and so on
})

Is this the appropriate way, how it's done in most cases?

Hope you can send me answer and thanks for your help!!


On 22 Dez., 02:11, Ricardo Tomasi  wrote:
> If you add the event handlers to the callback you can get it working:
>
> $("#content").load(loadLink, function(){
>    hideLoader();
>    $('.details').hide();
>    $('.showDetails').click(function() {
>         $('.details').slideToggle('slow');
>         return false;
>    });
>
> })
>
> On Dec 21, 4:20 pm, suntrop  wrote:
>
> > Sorry for that, but how can I bind the event after I call $
> > ("#content").load(loadLink,"",hideLoader);?
>
> > Do I have to replace hideLoader with a function that contains all the
> > "new" code?
>
> > Thanks for your help!
>
> > On 21 Dez., 17:30, DumpsterDoggy  wrote:
>
> > > You can't bind any events to the controls on $(document).ready() if
> > > the html isn't there. I would try binding the event after you call $
> > > ("#content").load(loadLink,"",hideLoader);
>
> > > On Dec 21, 10:17 am, suntrop  wrote:
>
> > > > Hi there.
>
> > > > I am loading some content into my page …
>
> > > >   $("#content").load(loadLink,"",hideLoader);
>
> > > > The file behind loadLink (e.g. contact.php) has some tables with
> > > > class="details" and I want them to be hidden and not shown until I
> > > > click the link before it.
>
> > > > $('.details').hide();
> > > > $('.showDetails').click(function() {
> > > >         $('.details').slideToggle('slow');
> > > >         return false;
>
> > > > });
>
> > > > But for some reason it doesn't work. The table .details is displayed
> > > > and when I click the link .showDetails nothing happens (I tried to
> > > > alert something, nothing here too).
>
> > > > I am afraid of it is not working with content loaded dynamically after
> > > > my page with the jQuery JS is loaded. Because jQuery doesn't knows the
> > > > "new" .details table??


[jQuery] Re: Can I "access" and change content loaded dynamically after jQuery.js?

2008-12-21 Thread Ricardo Tomasi

If you add the event handlers to the callback you can get it working:

$("#content").load(loadLink, function(){
   hideLoader();
   $('.details').hide();
   $('.showDetails').click(function() {
$('.details').slideToggle('slow');
return false;
   });
})

On Dec 21, 4:20 pm, suntrop  wrote:
> Sorry for that, but how can I bind the event after I call $
> ("#content").load(loadLink,"",hideLoader);?
>
> Do I have to replace hideLoader with a function that contains all the
> "new" code?
>
> Thanks for your help!
>
> On 21 Dez., 17:30, DumpsterDoggy  wrote:
>
> > You can't bind any events to the controls on $(document).ready() if
> > the html isn't there. I would try binding the event after you call $
> > ("#content").load(loadLink,"",hideLoader);
>
> > On Dec 21, 10:17 am, suntrop  wrote:
>
> > > Hi there.
>
> > > I am loading some content into my page …
>
> > >   $("#content").load(loadLink,"",hideLoader);
>
> > > The file behind loadLink (e.g. contact.php) has some tables with
> > > class="details" and I want them to be hidden and not shown until I
> > > click the link before it.
>
> > > $('.details').hide();
> > > $('.showDetails').click(function() {
> > >         $('.details').slideToggle('slow');
> > >         return false;
>
> > > });
>
> > > But for some reason it doesn't work. The table .details is displayed
> > > and when I click the link .showDetails nothing happens (I tried to
> > > alert something, nothing here too).
>
> > > I am afraid of it is not working with content loaded dynamically after
> > > my page with the jQuery JS is loaded. Because jQuery doesn't knows the
> > > "new" .details table??


[jQuery] Re: Can I "access" and change content loaded dynamically after jQuery.js?

2008-12-21 Thread Ryura

Try the liveQuery plugin:
http://docs.jquery.com/Plugins/livequery

On Dec 21, 1:20 pm, suntrop  wrote:
> Sorry for that, but how can I bind the event after I call $
> ("#content").load(loadLink,"",hideLoader);?
>
> Do I have to replace hideLoader with a function that contains all the
> "new" code?
>
> Thanks for your help!
>
> On 21 Dez., 17:30, DumpsterDoggy  wrote:
>
> > You can't bind any events to the controls on $(document).ready() if
> > the html isn't there. I would try binding the event after you call $
> > ("#content").load(loadLink,"",hideLoader);
>
> > On Dec 21, 10:17 am, suntrop  wrote:
>
> > > Hi there.
>
> > > I am loading some content into my page …
>
> > >   $("#content").load(loadLink,"",hideLoader);
>
> > > The file behind loadLink (e.g. contact.php) has some tables with
> > > class="details" and I want them to be hidden and not shown until I
> > > click the link before it.
>
> > > $('.details').hide();
> > > $('.showDetails').click(function() {
> > >         $('.details').slideToggle('slow');
> > >         return false;
>
> > > });
>
> > > But for some reason it doesn't work. The table .details is displayed
> > > and when I click the link .showDetails nothing happens (I tried to
> > > alert something, nothing here too).
>
> > > I am afraid of it is not working with content loaded dynamically after
> > > my page with the jQuery JS is loaded. Because jQuery doesn't knows the
> > > "new" .details table??


[jQuery] Re: Can I "access" and change content loaded dynamically after jQuery.js?

2008-12-21 Thread suntrop

Sorry for that, but how can I bind the event after I call $
("#content").load(loadLink,"",hideLoader);?

Do I have to replace hideLoader with a function that contains all the
"new" code?

Thanks for your help!


On 21 Dez., 17:30, DumpsterDoggy  wrote:
> You can't bind any events to the controls on $(document).ready() if
> the html isn't there. I would try binding the event after you call $
> ("#content").load(loadLink,"",hideLoader);
>
> On Dec 21, 10:17 am, suntrop  wrote:
>
> > Hi there.
>
> > I am loading some content into my page …
>
> >   $("#content").load(loadLink,"",hideLoader);
>
> > The file behind loadLink (e.g. contact.php) has some tables with
> > class="details" and I want them to be hidden and not shown until I
> > click the link before it.
>
> > $('.details').hide();
> > $('.showDetails').click(function() {
> > $('.details').slideToggle('slow');
> > return false;
>
> > });
>
> > But for some reason it doesn't work. The table .details is displayed
> > and when I click the link .showDetails nothing happens (I tried to
> > alert something, nothing here too).
>
> > I am afraid of it is not working with content loaded dynamically after
> > my page with the jQuery JS is loaded. Because jQuery doesn't knows the
> > "new" .details table??


[jQuery] Re: Can I "access" and change content loaded dynamically after jQuery.js?

2008-12-21 Thread DumpsterDoggy

You can't bind any events to the controls on $(document).ready() if
the html isn't there. I would try binding the event after you call $
("#content").load(loadLink,"",hideLoader);

On Dec 21, 10:17 am, suntrop  wrote:
> Hi there.
>
> I am loading some content into my page …
>
>   $("#content").load(loadLink,"",hideLoader);
>
> The file behind loadLink (e.g. contact.php) has some tables with
> class="details" and I want them to be hidden and not shown until I
> click the link before it.
>
> $('.details').hide();
> $('.showDetails').click(function() {
>         $('.details').slideToggle('slow');
>         return false;
>
> });
>
> But for some reason it doesn't work. The table .details is displayed
> and when I click the link .showDetails nothing happens (I tried to
> alert something, nothing here too).
>
> I am afraid of it is not working with content loaded dynamically after
> my page with the jQuery JS is loaded. Because jQuery doesn't knows the
> "new" .details table??