livesearch field id has changed
Jamroom Developers
A structure for live search looks like this:
$_tmp = array(
'name' => 'profile_user_id',
'group' => 'admin',
'label' => 'profile owner',
'help' => 'What User Account should this profile be created for? The User Account selected here will have admin capabilities for the Profile.',
'type' => 'live_search',
'target' => "{$_conf['jrCore_base_url']}/{$_post['module_url']}/get_profile_users",
'required' => false,
'validate' => 'number_nz',
'form_designer' => false
);
jrCore_form_field_create($_tmp);
the 'get_profile_users' function looks like this:
function view_jrProfile_get_profile_users($_post, $_user, $_conf)
{
jrUser_admin_only();
$lim = 12;
if (!empty($_post['limit']) && jrCore_checktype($_post['limit'], 'number_nz')) {
$lim = (int) $_post['limit'];
}
$_sc = array(
'search' => array(
"user_name like {$_post['q']}%"
),
'return_keys' => array('_user_id', 'user_name'),
'skip_triggers' => true,
'ignore_pending' => true,
'privacy_check' => false,
'limit' => $lim
);
$_rt = jrCore_db_search_items('jrUser', $_sc);
$_sl = array();
if ($_rt && is_array($_rt) && is_array($_rt['_items'])) {
foreach ($_rt['_items'] as $_v) {
$_sl["{$_v['_user_id']}"] = $_v['user_name'];
}
}
return jrCore_live_search_results('profile_user_id', $_sl);
}
If you only have one live_search on the page, it will have the class .live_search_text. You're wanting to get the ID for that right? If so, then you could do:
var id = $('.live_search_text').attr('id');
If you've got more than one, then we probably should add a unique class name into the core code, so there is a .live_search_unique_(field_name) in there too. You need that?
updated by @michael: 06/14/20 07:00:12PM