Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-17-2009, 11:29 PM   PM User | #1
earth2mac
New Coder

 
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
earth2mac is an unknown quantity at this point
jquery question function

I am using a script to change content in a window. I need the html contnet in window to be up by default. With this it's only up when you click link. What do I need to add to this?

<script type="text/javascript">
$(document).ready(function() {

$('#links a').click(function() {
var url=$(this).attr('href');
$('#headlines').load(url + ' #newsItems');
return false;
});
});
</script>
earth2mac is offline   Reply With Quote
Old 03-17-2009, 11:50 PM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
there has to be a way to set the variable beforehand. Where's the script? Find out what names are used, find out the one you want for default, set it to that one to begin with, and you're done.
TinyScript is offline   Reply With Quote
Old 03-18-2009, 02:51 PM   PM User | #3
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Or just add one line like this:

Code:
<script type="text/javascript">
    $(document).ready(function() {
        $('#links a').click(function() {
            var url=$(this).attr('href');
            $('#headlines').load(url + ' #newsItems');
            return false;
        });
        $('#links a').click();
    });
</script>
Essentially triggers the click event on the link in question. It can be changed otherwise too... like so:

Code:
<script type="text/javascript">
    $(document).ready(function() {
        var url=$('#links a').attr('href');
        $('#headlines').load(url + ' #newsItems');
    });
</script>
But what you use is really up to you. The second one will have no effect if people actually do decide to click on the link, and it will follow the link, so the first solution might be the better choice, depending on what you really want to do.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:06 PM.


Advertisement
Log in to turn off these ads.