Commit 36b7f184 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use json to submit search queries on find friends


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 558e6f27
......@@ -72,6 +72,13 @@ var Paginator = function(id, datatable, script, extradata) {
}
}
this.sendQuery = function(params) {
sendjsonrequest(self.jsonScript, params, 'GET', function(data) {
self.updateResults(data);
self.alertProxy('pagechanged', data['data']);
});
}
this.rewritePaginatorLink = function(a) {
connect(a, 'onclick', function(e) {
e.stop();
......@@ -83,10 +90,7 @@ var Paginator = function(id, datatable, script, extradata) {
queryData.extradata = serializeJSON(self.extraData);
}
sendjsonrequest(self.jsonScript, queryData, 'GET', function(data) {
self.updateResults(data);
self.alertProxy('pagechanged', data['data']);
});
self.sendQuery(queryData);
});
}
......
......@@ -41,8 +41,6 @@ $data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id')
$data['query'] = $query;
build_userlist_html($data, 'find');
$js = 'addLoadEvent(function () {' . $data['pagination_js'] . '});';
$searchform = pieform(array(
'name' => 'search',
'renderer' => 'oneline',
......@@ -58,6 +56,16 @@ $searchform = pieform(array(
)
));
$js = <<< EOF
addLoadEvent(function () {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function () {
var params = {'query': $('search_query').value};
p.sendQuery(params);
});
});
EOF;
$smarty = smarty(array('paginator'), array(), array(), array('sideblocks' => array(friends_control_sideblock('find'))));
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->assign('INLINEJAVASCRIPT', $js);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment