Putting together a very basic query builder using or
, not
and ()
operators. I have them appending to an input field though I think it would be beneficial to the user if when the brackets operator button was appended to the input field the cursor would be placed (here)
ready for the users query.
So far I have:
// query builder functions
$(function() {
var queryinput = $( "#query-builder-modal .search-box input.querybuilder" );
$('#query-builder-modal ul.operators li.or').click(function(){
queryinput.val( queryinput.val() + "OR" );
queryinput.focus();
});
$('#query-builder-modal ul.operators li.not').click(function(){
queryinput.val( queryinput.val() + "-" );
queryinput.focus();
});
$('#query-builder-modal ul.operators li.brackets').click(function(){
queryinput.val( queryinput.val() + "()" );
queryinput.focus();
});
});
Can anyone help me plave the cursor between the brackets in the third click function of this sample code?
Thanks in advance