Jump to content
php.lv forumi
  • 0

Viena jquery f-ja iekš otras


senters

Question

Ar šādu jquery konfigu izpildas kategoriju dropdown:

 

// Kategoriju filtrs [JQUERY]
$(function(){
$('#filter_category').click(function(){
$('ul.menu_category').slideToggle('medium');
$('ul.menu_category a').click(function(){
var category_id = $(this).attr("id");
$.ajax(
{
type: "POST",
url: "inc/category_results.php",
data: "category_id="+ category_id,
cache: false,
success: function(html)
{
$(".spotlight, .spotlight_switch, .all_events").empty();
$(".today_events").html(html);
}
});
});
});
});

 

Un ar šādu jquery konfigu tiek dalīti ieraksti lapās, izmantots jquery datatable libs:

 

// Kategoriju ieraksti [JQUERY Datatable]
<?php
$d = "SELECT COUNT(*) FROM event WHERE category_id = '".$category_id."'";
$q = mysql_query($d);
$r = mysql_fetch_row($q);
$cat_event_count = $r['0'];
if ($cat_event_count <= 5) { $pag_stat = "false"; } else { $pag_stat = "true"; }
?>
$(document).ready(function() {
$("#datatable_categoryevents").dataTable ({
"bPaginate": <?php echo $pag_stat; ?>,
"sPaginationType": "full_numbers",
"bSort": false,
"bFilter": false,
"iDisplayLength": 5,
"bLengthChange": false,
"bInfo": false
});
}); 

 

Problēma:

 

Viss ir ok ar pašu dropdown kategoriju izvēlni, smuki nostrādā ajax datu ielasīšana no db. Bet kā panākt, ka tālāk nostrādā arī šo datu sadale lapās (2. jquery konfiga bloks)?

Edited by senters
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Atrisināju pats beigās

 

 

<?php
$d = "SELECT COUNT(*) FROM event WHERE category_id = '".$category['id']."'";
$q = mysql_query($d);
$r = mysql_fetch_row($q);
$cat_event_count = $r['0'];
if ($cat_event_count <= 5) { $pag_stat = "false"; } else { $pag_stat = "true"; } 
?>
// Kategoriju filtrs [JQUERY]
$(function(){
$('#filter_category').click(function(){
$('ul.menu_category').slideToggle('medium');
$('ul.menu_category a').click(function(){
var category_id = $(this).attr("id");
//alert(category_id);
$.ajax(
{
type: "POST",
url: "inc/category_results.php",
data: "category_id="+ category_id,
cache: false,
success: function(html)
{
$(".spotlight, .spotlight_switch, .all_events").empty();
$(".today_events").html(html);
$("#datatable_categoryevents").dataTable ({
"bPaginate": <?php echo $pag_stat; ?>,
"sPaginationType": "full_numbers",
"bSort": false,
"bFilter": false,
"iDisplayLength": 5,
"bLengthChange": false,
"bInfo": false
});
}
});
}); 
});
});

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...