oldmanInAz
02-23-2011, 06:01 AM
I have found many useful scripts on DD that I have employed at various times.
For once, I thought I'd pass on to you a simple script you should employ in many of your items.
You know like that "Ajax content" one with the cars?
My philosophy has always been, "KISS it. Keep it simple, stupid".
Now talk about sweet and simple coding, this is it.
I, and others, have been looking for a way to call items from one "master" page, rather than loading a long string of crap onto the main page. Where your script relies on calling individual pages, this script uses one page.
I did not author this. But I thought I'd share it with you and others.
The author is "Scott Sauyet" http://sauyet.com.
<style type="text/css">
#itemsToSelect {width: 25%; float: left; background-color: #ffc}
#itemDisplay {width: 70%; float: left; background-color: #0ff;}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $display = $("#itemDisplay");
$("body").delegate("a.item", "click", function(evt) {
$display.load(this.href.replace("#", " #"));
evt.preventDefault();
});
});
</script>
Linking is even simpler
<a href="page.html#item1">item 1</a>
The key in the link is after # and before the number.
If you want to use something other than "item" then also make the change in the script above to reflect "<a.whatever".
AFAIK, what's after the "key" is irrelevant.
Have fun.
For once, I thought I'd pass on to you a simple script you should employ in many of your items.
You know like that "Ajax content" one with the cars?
My philosophy has always been, "KISS it. Keep it simple, stupid".
Now talk about sweet and simple coding, this is it.
I, and others, have been looking for a way to call items from one "master" page, rather than loading a long string of crap onto the main page. Where your script relies on calling individual pages, this script uses one page.
I did not author this. But I thought I'd share it with you and others.
The author is "Scott Sauyet" http://sauyet.com.
<style type="text/css">
#itemsToSelect {width: 25%; float: left; background-color: #ffc}
#itemDisplay {width: 70%; float: left; background-color: #0ff;}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $display = $("#itemDisplay");
$("body").delegate("a.item", "click", function(evt) {
$display.load(this.href.replace("#", " #"));
evt.preventDefault();
});
});
</script>
Linking is even simpler
<a href="page.html#item1">item 1</a>
The key in the link is after # and before the number.
If you want to use something other than "item" then also make the change in the script above to reflect "<a.whatever".
AFAIK, what's after the "key" is irrelevant.
Have fun.