How do I make the label in storage, detect uniqueness, and continue to use the non-repeating insert?

Source: Internet
Author: User

I'm using Select2 as a tagging feature for users,

    • 1 is the select2 listed directly in the label, including the user input, together to the background, and then processing, now stuck in a set of data into the background, I need to detect the label duplication, and only store non-duplicate tags, continue to use, how do I do this label function?

    • 2 using SELECT2 Ajax to store tags in advance, how do you use Select2? How does the Ajax return value be tied to the input box? Do you use the DOM operation?

    • How is the default value in 3select2 canceled? and binding

    • Thank you!

Reply content:

I'm using Select2 as a tagging feature for users,

    • 1 is the select2 listed directly in the label, including the user input, together to the background, and then processing, now stuck in a set of data into the background, I need to detect the label duplication, and only store non-duplicate tags, continue to use, how do I do this label function?

    • 2 using SELECT2 Ajax to store tags in advance, how do you use Select2? How does the Ajax return value be tied to the input box? Do you use the DOM operation?

    • How is the default value in 3select2 canceled? and binding

    • Thank you!

Finally, the problem is solved first, the function of the label has been completed.

    • Use Select2, and then send the data to the background for processing, Select2 passed over the existing label is the tag ID, this time with this ID to determine whether the ID exists, if there is skip the cycle, the other values insert tag name, get tag ID, The tag ID corresponding to the previous array of the key to modify, and then the resulting array is all ID number, directly stored.

    • However, there may be a problem: if you enter a label name that already exists with the same name as the ID number, it will be filtered together

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.