Created
July 8, 2013 16:50
-
-
Save pbrewczynski/5950472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<ul id="my-feature"> | |
<li id="1">Go on </li> | |
<li id="2">Go on </li> | |
<li id="3">Go on </li> | |
<li id="4">Go on </li> | |
<li id="5">Go on </li> | |
<li id="6">Go on </li> | |
<li id="7">Go on </li> | |
</ul> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*$(document).ready(function () { | |
$("#my-feature li") | |
.append("<div/>") | |
.each(function () { | |
$(this).find('div') | |
.load('http://twigit.pl/module.php?item=' + | |
$(this).attr('id')); | |
}) | |
.click(function () { | |
$(this).find('div').show("slow"); | |
$(this).siblings().find('div').hide(); | |
}); | |
});*/ | |
var myFeature = { | |
config : { | |
wrapper : '#my-feature', | |
container: 'div', | |
urlBase : 'http://twigit.pl/module.php?item=' | |
}, | |
init : function (config) { | |
$.extend(myFeature.config, config); | |
$(myFeature.config.wrapper).find("li") | |
.each(function () { | |
myFeature.getContent($(this)); | |
}). | |
click(function () { | |
myFeature.showContent($(this)); | |
}); | |
}, | |
buildUrl : function ($li) { | |
return myFeature.config.urlBase + $li.attr("id"); | |
}, | |
getContent : function ($li) { | |
$li.append(myFeature.config.container); | |
var url = myFeature.buildUrl($li); | |
$li.find(myFeature.config.container).load(url); | |
}, | |
showContent : function ($li) { | |
$li.find('div').show(); | |
console.log($li.find('div')); | |
myFeature.hideContent($li.siblings()); | |
}, | |
hideContent : function ($elements) { | |
$elements.find('div').hide(); | |
} | |
}; | |
$(document).ready( function () { myFeature.init(); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment