php - Reload the table with JQuery -
i have following issue. here index.php :
<div id="tabs"> <ul> <li><a href="#tabs-1">a projects</a></li> <li><a href="#tabs-2">b projects</a></li> </ul> <div id="tabs-1"> <?php echo loadtabs(1);?> </div> <div id="tabs-2"> <?php echo loadtabs(2);?> </div>
here 2 php functions build tables:
function loadtabs($settingid){ $query = 'select * deployments_settings id="'.$settingid.'"'; $result = mysql_query($query); $html = '<div id="tab'.$settingid.'_container">'; while ($row = mysql_fetch_array($result)) { $html .= '<div id="tab'.$settingid.'_buttons">'; $html .= '<button id="add_project">'.$row['addbuttoncaption'].'</button>'; $html .= '</div>';// id="tab[1..2]_button_add" $html .= '<div id="tab'.$settingid.'_content">'; $html .= '<br/>'; $html .= loadtables($settingid, $row['deploymentstable']); $html .= '</div>';//id=tab[1..2]_[first..second]content }//while $html .= '</div>';// id="tab[1..2]_container" return $html;} function loadtables( $tableid, $tablename ) { $query = 'select * '.$tablename.' order `id` desc'; $result = mysql_query($query); $html = '<table id="tab'.$tableid.'_table" class="tabtable">'; $html .= '<thead><tr>'; $html .= '<th>#</th>'; $html .= '<th>project number</th>'; $html .= '<th>deadline</th>'; $html .= '<th>assign to</th>'; $html .= '<th>description</th>'; $html .= '<th>action</th>'; $html .= '</tr></thead>'; $html .= '<tbody>'; $countrow = 0; while ($row = mysql_fetch_array($result)) { $html .='<tr>'; $html .= '<td class="colid">'.++$countrow.'</td><td class="colpn">'.$row['name'].'</td><td class="coldl">'.$row['deadline'].'</td><td class="colat">'.$row['assignto'].'</td><td>'.$row['description'].'</td>'; $html .= '<td class="colact">'; $html .= '<button id="edit_action">edit</button>'; $html .= '<button title="remove" contentreload="'.$tableid.'" rrtable="'.$tablename.'" rrid="'.$row['id'].'" id="delete_action">delete</button>'; $html .= '</td>'; $html .= '</tr>'; }//while $html .= '</tbody>'; $html .= '</table>'; return $html;}
here jquery part button delete.
$( "button#delete_action") .button({icons: {primary: "ui-icon-circle-minus"}, text: false}) .click(function() { var contentreload = $(this).attr("contentreload"); //alert(contentreload); if(confirm("press ok confirm delete operation")) { $.post("coredb.php", { action: 3, rrtable: $(this).attr("rrtable"), rrid: $(this).attr("rrid"), contentreload: $(this).attr("contentreload") }, function(data, textstatus, xmlhttprequest) { //alert(data); $("#tab"+ contentreload + "_table").html(data); }); //post } //if condition });
the issue -> when "delete button" run gives table output re-apply table object$("#tab"+ contentreload + "_table").html(data);
. unfortunately doesn't reload the table , goodies jquery don't work too.
is need work on jquery side in order reload table.
thank in advance!
i haven't read above code it's pretty hard read, if you're wanting delete rows table, i'd fire ajax call delete script. then, if ajax call returns true, remove row table javascript. means page doesn't have refreshed then.
Comments
Post a Comment