Awesome q2a theme

Javascript. How to return multiple values using a comma?

0 like 0 dislike
51 views
Good afternoon. Here my demo calendar for DHTLMX.
The point is that when you create an event on the calendar I want to click on the checkboxes in the section username to click Save and they should replace the standard text of the New Event. It should look like that. We create,choose, let's say Kate,Mary, save and text New Event is replaced with "Kate,Mary".
But in this scenario in my demo text replaced if someone selected only one. Let Kate, and when a few - not replaced...
Please tell me where can be error? Thank you
by | 51 views

2 Answers

0 like 0 dislike
scheduler.attachEvent("onEventSave",function(id,ev,is_new){ const keys = ev.username.split(','); const selectedUsers = users.filter(user => keys.includes(user.key)).map(user => user.label); ev.text = selectedUsers.join(','); return true; })
by
0 like 0 dislike
scheduler.attachEvent("onEventSave",function(id,ev,is_new) { var checked_users = ev.username.split(','); // translate string into a list of noted user id var with new_text = "; // here we write a string with user names var checked_users_count = checked_users.length; // number of checked users for (var i = 0; i < checked_users_count; i++) { var check_user_id = checked_users[i]; // current id noted var ch_users = users.filter(usr => usr.key == check_user_id); // get the person from the list of users marked for id (the output is also a list, but no more than 1 element) if (ch_users.length > 0) with new_text += (with new_text != "? ', ' : ") + ch_users[0].label; // is entered in the user row was found } ev.text = with new_text == " ? 'Nobody' : with new_text; // if no found then we denote this situation (Nobody) return true; })
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users