Giter Club home page Giter Club logo

Comments (8)

ivaynberg avatar ivaynberg commented on May 28, 2024

what do you mean by "reload"?

from select2.

allochi avatar allochi commented on May 28, 2024

Well, if I hit refresh, I mean reload the whole page which contains the form, in my case, if I access that a page with a form editing a record in the database, and that keyword_list value is "Red,Blue", it will do the same.

from select2.

ivaynberg avatar ivaynberg commented on May 28, 2024

that seems rather peculiar because it does not happen here:

http://ivaynberg.github.com/select2/

under the tagging example. no matter how many times i reload the page Blue and Brown are always selected....

are there any javascript errors in the console?

from select2.

allochi avatar allochi commented on May 28, 2024

Nope, there is none, I tried also to see if there is something wrong with postprocessResults(), but I can't get windows.console.log to work in your code, anyway, I think it's this function that is causing this, till yesterday, all what I found was, it does add select2-disabled for the first choice, but it stop there, the others never get it.

I can help more if you tell me what is the trick with console.log, I don't want to throw all the work on your direction, you are already doing AMAZING job with select2. and I can't wait for your next project :)

from select2.

ivaynberg avatar ivaynberg commented on May 28, 2024

run the app in chrome, it has a native js console you can open. you can write to it by simply saying console.log('foo')

also make sure your hidden element's value really says Red,Blue

from select2.

allochi avatar allochi commented on May 28, 2024

Well, I do that, I mean, I'm using chrome, and I do use console.log debugging my JS, it's only when I add console.log to your code it doesn't work, strange for me, I tried also window.console.log, I will try to use chrome debugger to see what is going on here. and I will update you with I'll get. Thanks Igor for following up.

from select2.

allochi avatar allochi commented on May 28, 2024

Latest thing I reached is that while initialization in postprocessResults this line:

choices = this.results.find(".select2-result")

return empty array, although the value of the field is set and return the comma separated tags

from select2.

allochi avatar allochi commented on May 28, 2024

Man! after so many hours going and coming back to the problem I found out why it behaves that way!!!

if I have the field's value

"red,blue,green"

there is then no problem, but my code (rails + act_as_taggable_on) returns

"red, blue, green"

so basically we need to trim leading and trailing spaces when we split the value, following your code, in AbstractSelect2#prepareOpts, the line

data.push({id: this, text: this});

should be

var text = $.trim(this);
data.push({id: text, text: text});

from select2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.