stuck with functions plugin
hello every body
i made a rating system based on the one that in the main tutorial and now i wanted to right it on a seperate file so that at the end i will just add it to my page.
i made it as a function and i called it:
jquery.rating.js
i saved this file in the same directory of the Jquery.js file.
this is how my file looks like:
-
jQuery.fn.rating = function(options) {
var settings = jQuery.extend({
url: ""
}, options);
for ( var i = 1; i <= 5; i++ )
$("#unit_ul").append("<li><a href='#' id='" + i + "' class='r" + i + "-unit rater'></a></li>");
$("#unit_ul a[@id='1']").click(function(){
$.post(url + "1", {unit_ul: $(this).html()}, function(xml) {
$("#unit_ul").html(
"<li class='current-rating' style='width:" + $("average", xml).text() + "px'></li>"
);
$("#rate_title").html("תודה על הדירוג!");
});
return false;
});
$("#unit_ul a[@id='2']").click(function(){
$.post(url + "2", {unit_ul: $(this).html()}, function(xml) {
$("#unit_ul").html(
"<li class='current-rating' style='width:" + $("average", xml).text() + "px'></li>"
);
$("#rate_title").html("תודה על הדירוג!");
});
return false;
});
$("#unit_ul a[@id='3']").click(function(){
$.post(url + "3", {unit_ul: $(this).html()}, function(xml) {
$("#unit_ul").html(
"<li class='current-rating' style='width:" + $("average", xml).text() + "px'></li>"
);
$("#rate_title").html("תודה על הדירוג!");
});
return false;
});
$("#unit_ul a[@id='4']").click(function(){
$.post(url + "4", {unit_ul: $(this).html()}, function(xml) {
$("#unit_ul").html(
"<li class='current-rating' style='width:" + $("average", xml).text() + "px'></li>"
);
$("#rate_title").html("תודה על הדירוג!");
});
return false;
});
$("#unit_ul a[@id='5']").click(function(){
$.post(url + "5", {unit_ul: $(this).html()}, function(xml) {
$("#unit_ul").html(
"<li class='current-rating' style='width:" + $("average", xml).text() + "px'></li>"
);
$("#rate_title").html("תודה על הדירוג!");
});
return false;
});
});
and this is the page that i am using this code:
-
<script type="text/javascript">
$(...).rating({ url: <?=site_url_rel("show/rate/".$rank_id."/")?> });
</script>
though it doesn't work... any ideas?
thanks!