How to place 2 parameters to the input tag when the page is loaded

0

I am using the Bootstrap Tags Input plugin, and generating a dynamic table with php that I load through jquery with the Load method. This table has inputs where I show with tags what is stored there, for this I do so:

<input type='text' value='prueba, otra prueba' data-role='tagsinput'/>

and in javascript:

jQuery('input').tagsinput('refresh');

The problem is that the label that is loaded only has 1 parameter which is the name of the label and I need you to have the ID too. How can I do that?. In the plugin documentation it says like this:

$('input').tagsinput('add', { id: 1, text: 'some tag' });

But I can not do it because the table is generated in an external file that I load, as I said, with the Load method of Jquery. I hope I could explain and thank you very much!

    
asked by Patricio 15.09.2018 в 21:33
source

1 answer

0

I have not actually used Bootstrap Tags Input, but according to the documentation , you would have to initialize the input as follows

 $('.input').tagsinput({
      allowDuplicates: false,
        itemValue: 'id',  // Será usado para el id
        itemText: 'label' // Será usado para el texto
    });

Afterwards, you could do what you want

$('input').tagsinput('add', { id: '0', label: 'EjemploTexto' });

Greetings

    
answered by 15.09.2018 в 23:05