Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select2 Tags not working well on v4.0.3? #979

Open
lshaf opened this issue Feb 16, 2017 · 5 comments
Open

Select2 Tags not working well on v4.0.3? #979

lshaf opened this issue Feb 16, 2017 · 5 comments

Comments

@lshaf
Copy link

lshaf commented Feb 16, 2017

Here's my code

    $('a.tag_edit').editable({
        select2: {
          tags: true,
          tokenSeparators: [',', ' ']
        },
        success: function(response, newValue){
          if(response.status != 200) return response.message;
          $(this).html(response.value);
        },
        error: function(response, newValue) {
          return response.responseText;
        }
      });

HTML

<a href="#" class="tag_edit" data-type="select2" data-name="tags" data-url="/order/ajax/update/order_master" data-placeholder="Tags Order" data-pk="'+data.id+'"></a>

What I expected is displaying Tags editor but here is what I got
image

it show normal select2, I've tried fill tags using array but not work.
btw I'm using select2.full.min.js because Uncaught Error: No select2/compat/inputData

@MarQuisKnox
Copy link
Contributor

Please create a demo on JS Fiddle or JS Bin

@lshaf
Copy link
Author

lshaf commented Feb 16, 2017

here is my demo Fiddle

@lshaf
Copy link
Author

lshaf commented Feb 17, 2017

here is my second test Update Fiddle

@Philippe12
Copy link

Hello

You ca see the problem if you active the debug mode

$('a.tag_edit').editable({
        select2: {
          debug:true,
          tags: true,
          tokenSeparators: [',', ' ']
        },
        success: function(response, newValue){
          if(response.status != 200) return response.message;
          $(this).html(response.value);
        },
        error: function(response, newValue) {
          return response.responseText;
        }
      });

with this option we have a warning 'Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a <select> element instead.'

I correct the problem to change the html tag from input to select.

 src/inputs/select2/select2.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/inputs/select2/select2.js b/src/inputs/select2/select2.js
index 0b3a7f3..d6d0f46 100644
--- a/src/inputs/select2/select2.js
+++ b/src/inputs/select2/select2.js
@@ -312,7 +312,7 @@ $(function(){
         @property tpl 
         @default <input type="hidden">
         **/
-        tpl:'<input type="hidden">',
+        tpl:'<select type="hidden">',
         /**
         Configuration of select2. [Full list of options](http://ivaynberg.github.com/select2).
 

@MarQuisKnox MarQuisKnox self-assigned this May 9, 2017
@mlt
Copy link

mlt commented Jun 10, 2020

Duplicate for #756?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants