Reputation: 7766
I am using jquery token input for search purpose in a texbox in my MVC pjct as below
(".diag").tokenInput("@Url.Action("SearchDiagnosis","Preapproval")",
{
theme: 'facebook',
preventDuplicates: true,
searchingText: 'Searching diagnosis code...',
tokenLimit: 1,
hintText: 'Diagnosis Code'
});
by default the query parameter 'q' will be passed and return the desired result.
this text is under a table. In the same row there is a dropdownlist. Now my requirement is while searching happens in jquery token input i need to pass the selected value of the dropdownlist also. Is it possible?
Edited
var qq;
$("#service").on('change', '.act_type', function () {
{
qq = $(this).val();
});
$("#service").find(".act_code").last().tokenInput("../Preapproval/SearchDiagnosis?queryParam=q" + "&type="+qq,
{
theme: 'facebook',
preventDuplicates: true,
searchingText: 'Searching...',
tokenLimit: 1,
hintText: 'Activity code'
});
the table row is creating dynamically and assigning tokeninput the class.
public JsonResult SearchDiagnosis(string q, string type)
{...
}
I changed the code like this
$("#service").on('change', '.act_type', function () { //$(".diag").change(function () {
qq = $(this).val();
var id = $(this).attr('id').split('-');
$("#code-"+id[1]).tokenInput("../Preapproval/Searchactivitycode?queryParam=q" + "&type=" + qq,
{
theme: 'facebook',
preventDuplicates: true,
searchingText: 'Searching...',
tokenLimit: 1,
hintText: 'Activity code'
});
Now it pass the correct value assigned to qq. But now iam facing another issue. if the dropdown in the same row is changed more than one time that much number of texbox will be created with tokeninput because he tokeninput is assigning at the change event. Is there any solution to stop this?
Edited
I searched a lot for assigning this to a dynamic created row didn't got any. Please help.
Upvotes: 2
Views: 1755
Reputation: 9267
this can be achieved by onSend
callback of the plugin
jquery tokeninput filter query send extra parameters
Upvotes: 0
Reputation: 1222
Try something simple like below
$(".diag").tokenInput("/SearchDiagnosis/Preapproval?queryParam=q" + "&type=qq",
{ tokenLimit: 1, });
Upvotes: 2