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
Post a Comment