javascript - how to populate a multiple email field with data in edit mode -




i have input text contains multiple emails, used this plugin it's working fine when type emails field.

the problem when saved form , try edit values not displayed field ..

how display emails field using javascript or jquery ?

this jquery code show emails field :

 $('#id_emails').multiple_emails(); 

i tried change value of field :

$('.multiple_emails-input').val({{ emails|safe }}); 

this what's in html :

<input type="text" class="multiple_emails-input text-left"> r@gmail.com ra@gmail.com r2h@gmail.com </input> 

where {{emails}} emails list returned server, nothing shown

could me on ?

it seems plugin hasn't api reset , repopulate list, can try emulate user actions (although not nice way).

for example:

//remove items $('.multiple_emails-email .glyphicon-remove').click();  //add new item: $('.multiple_emails-input').val('test@new.email').blur(); $('.multiple_emails-input').val('test@new.email').blur(); //for reason  //must called twice when adding first new item (i don't know why) //second item: $('.multiple_emails-input').val('one@more.email').blur(); 

this code works on demo-page.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -