meteor-select2 icon indicating copy to clipboard operation
meteor-select2 copied to clipboard

Dropdown/clear images not showing up and config options not taking affect.

Open sturoid opened this issue 10 years ago • 10 comments

I'm not sure what I'm doing wrong but the select2 images I listed above and many of the config options aren't working for me like placeholder, and allowClear. The "width" config option works however. I would greatly appreciate any help. Here is the relevant code:

Template.contactsNew.rendered = ->
  # Initialize select boxes
  $('#status-select').select2
    allowClear: true
    placeholder: 'Select a status'
    width: '100%'

label Status
  select#status-select(name='status')
    option(value='active')    Active
    option(value='inactive')  Inactive
    option(value='prospect')  Prospect
    option(value='calling')   Calling

screen shot 2014-12-18 at 12 07 34 am

sturoid avatar Dec 18 '14 07:12 sturoid

I actually just saw this in the console:

Resource interpreted as Image but transferred with MIME type text/html: "http://localhost:3000/select2x2.png".

Do you know why it would be doing this?

sturoid avatar Dec 18 '14 07:12 sturoid

having the same problem. would appreciate some help/tip on how to resolve this.

thomasspiesser avatar Jan 21 '15 15:01 thomasspiesser

@thomasspiesser I actually fixed this but it wasn't ideal. I took the image and and put it in the /public folder of the project. For the placeholder, I added an empty "option" to the top of the select. That fixed everything. I'm not sure why Meteor doesn't find the assets of the packages sometimes. I've had this happen on two other packages now.

sturoid avatar Jan 21 '15 16:01 sturoid

@sturoid thanks mate! that fixes the problem even though it isn't ideal.

thomasspiesser avatar Jan 21 '15 20:01 thomasspiesser

@thomasspiesser Glad I could help!

sturoid avatar Jan 21 '15 20:01 sturoid

I seem to have this happening too in Meteor 1.0.3.1 ... any relationship to https://github.com/meteor/meteor/issues/2602?

rgm avatar Feb 17 '15 04:02 rgm

Thanks for linking that. It could definitely be the problem.

sturoid avatar Feb 17 '15 04:02 sturoid

Yes, that seems to be the problem. A call to e.g. http://localhost:3000/packages/natestrauser_select2/lib/select2/select2.png works. Should the image references in the css files be hardcoded? If that is the solution, I could submit a quick PR.

wursttheke avatar Mar 21 '15 18:03 wursttheke

In the meantime (waiting on stable Select2 4.0 for nate's official Atmosphere package), you can just download abhishekbatra's fork as a .zip, copy its contents into your app's packages/ folder and then meteor add select2. It solves this issue, at least.

kitnato avatar Apr 24 '15 16:04 kitnato

Interesting thing is that some of the urls are rewritten (at least for me looking at the chrome devtools), like:

.select2-search-choice-close { (..) background: url('packages/natestrauser_select2/lib/select2/select2.png') right top no-repeat; }

Even though the css file points directly to select2.png. I don't understand that. It would be great if this (rewrite) was a default behavior for css files.

Overwriting the css in a custom files feels wrong - it might break if the original css file changes.

For now I'm gonna copy the files to public/ ..

lgandecki avatar Jun 10 '15 17:06 lgandecki