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

It does not work with the latest version of materialize #52

Open
fabryss opened this issue May 9, 2018 · 29 comments
Open

It does not work with the latest version of materialize #52

fabryss opened this issue May 9, 2018 · 29 comments

Comments

@fabryss
Copy link

fabryss commented May 9, 2018

It does not work with the latest version of materialize 1.0.0-rc.1
Does anyone know a solution?
Thanks so much

ERROR MESSAGE:

Uncaught TypeError: Cannot set property 'tabIndex' of null
at s.value (materialize.min.js?ver=4.9.5:6)
at new s (materialize.min.js?ver=4.9.5:6)
at Function.value (materialize.min.js?ver=4.9.5:6)
at Function.value (materialize.min.js?ver=4.9.5:6)
at r.fn.init.jQuery.fn.(/orariautobus/anonymous function) [as dropdown] (https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js?ver=4.9.5:6:12862)
at r.fn.init.$.fn.materialize_autocomplete (jquery.materialize-autocomplete.min.js?ver=4.9.5:1)
at HTMLDocument. (scripts.js?ver=4.9.5:50)
at j (jquery-3.2.1.min.js?ver=4.9.5:2)
at k (jquery-3.2.1.min.js?ver=4.9.5:2)

@AkshayChordiya
Copy link

I'm facing the same issue

@yuvalherziger
Copy link

+1
I'd try to contribute to solving this when I'll find time, thanks for this plugin 😉

@AkshayChordiya
Copy link

AkshayChordiya commented Jun 29, 2018

I tried from my side to fix, couldn't do it (Not expert in CSS-JS stuff). This library is amazing and really needs to update to the new version of Materializecss.

@viclotana
Copy link

same issue here

1 similar comment
@b00leant
Copy link

same issue here

@Sander0542
Copy link

Is this fixed?

@AdamTyler
Copy link

I'm seeing this issue still

@avidus3r
Copy link

Came across this looking for answers. Wasn't able to find much so I dug into it a little further and noticed that it appends the ul dropdown to the first parent element of .input-field. In my case I didn't have that element.

After I added that class, all good. My html below:

<div class="col s4 center search input-field"> <!-- added .input-field -->
    <input class="autocomplete" type="text" id="autocomplete-input" placeholder="Search" />
</div>

@aniplaylist
Copy link

aniplaylist commented Sep 28, 2018

@avidus3r I don't think you are using Materialize in its latest version (yours is probably < 1.0.0)

The issue is linked to all the changes done to the Dropdown component : https://github.com/Dogfalo/materialize/blob/v1-dev/v1-upgrade-guide.md#dropdown

I took Materialize Autocomplete's demo and tried to fix the issue by replacing Materialize's CDN to 1.0.0 instead of 0.9.7, and applied changes listed in the changelog. You can find the result here : https://codepen.io/WillyReyno/pen/wYBaeP

You'll notice that the error is not displayed anymore, however the dropdown list is not triggered without clicking on the label... I don't understand why.

Any ideas?

@icefox0801 do you plan to upgrade this package to be compatible with Materialize 1.0.0 ?

@rubendinho
Copy link

I am also experiencing this problem with Materialize 1.0.0.

@luisolf
Copy link

luisolf commented Oct 24, 2018

I was able to make the multiple autocomplete working on Materialize 1.0.0 by changing the main autocomplete js and adding some local jquery. Thanks to @AngyNoT to point out the start path.

It's certainly not the best solution and I didn't have the time to test it, use at your own risk.

Steps to make it work:

  1. Download the changed "jquery.materialize-autocomplete.js" from the link below. I forked it on my account and changed just this file, the others remain exactly equal to @icefox0801 version, if you decide to use it on your project, you will have to minify the file by yourself as the minified file on my fork is unchanged. Basically what was changed inside the "jquery.materialize-autocomplete.js" was the Materialize DropDown object method "_getDropDownPosition", and also the dropdown initialization.

https://github.com/luisolf/materialize-autocomplete

2)Change the data-trigger attribute to data-target on your input element.

3)Call the function below on your ajax success function, inside the getData autocomplete method, after the callback call, and also on the input event of your input element.

var updateDropdown = function (id_ele) { var elem = document.getElementById(id_ele); var instance = M.Dropdown.getInstance(elem); if(instance) { if(!instance.isOpen) instance.open(); instance.recalculateDimensions(); } }

@nosahama
Copy link

Hey guys, I am also experiencing this problem with Materialize v1.0.0. I am using it with Django and crispy forms, for some weird reason I get an error when i follow the base sample on the materialize website Autocomplete, this is even before i insert my own data and it is so discouraging.

Any clear thoughts so far on a possible solution to this issue?

@luisolf
Copy link

luisolf commented Dec 20, 2018

Hey guys, I am also experiencing this problem with Materialize v1.0.0. I am using it with Django and crispy forms, for some weird reason I get an error when i follow the base sample on the materialize website Autocomplete, this is even before i insert my own data and it is so discouraging.

Any clear thoughts so far on a possible solution to this issue?

Just follow the steps I posted above to make it work on Materialize 1.0.0.

@nosahama
Copy link

Hey guys, I am also experiencing this problem with Materialize v1.0.0. I am using it with Django and crispy forms, for some weird reason I get an error when i follow the base sample on the materialize website Autocomplete, this is even before i insert my own data and it is so discouraging.
Any clear thoughts so far on a possible solution to this issue?

Just follow the steps I posted above to make it work on Materialize 1.0.0.

Haha, you clearly say Use at your own risk lol, but i would give it a try. Thanks a lot.

@luisolf
Copy link

luisolf commented Dec 21, 2018

Hey guys, I am also experiencing this problem with Materialize v1.0.0. I am using it with Django and crispy forms, for some weird reason I get an error when i follow the base sample on the materialize website Autocomplete, this is even before i insert my own data and it is so discouraging.
Any clear thoughts so far on a possible solution to this issue?

Just follow the steps I posted above to make it work on Materialize 1.0.0.

Haha, you clearly say Use at your own risk lol, but i would give it a try. Thanks a lot.

Just test it like you normally do with other stuff and see it fits your needs, So far I think it is working decently.

@tayhimself
Copy link

Just wanted to quickly add that this is caused by the missing input-field class as pointed out @avidus3r earlier this thread. @nosahama, this is indeed what @luisolf modification does. I would rather update my code to always have input-field class rather than add extra stuff on top.

@luisolf
Copy link

luisolf commented Jan 3, 2019

Just wanted to quickly add that this is caused by the missing input-field class as pointed out @avidus3r earlier this thread. @nosahama, this is indeed what @luisolf modification does. I would rather update my code to always have input-field class rather than add extra stuff on top.

All my previous autocomplete inputs in old Materialize already had input-field class on parent element, are you sure you are using Materialize 1.0.0?

@nosahama
Copy link

nosahama commented Jan 4, 2019

Just wanted to quickly add that this is caused by the missing input-field class as pointed out @avidus3r earlier this thread. @nosahama, this is indeed what @luisolf modification does. I would rather update my code to always have input-field class rather than add extra stuff on top.

What version of Materialize are you using?

@luisolf
Copy link

luisolf commented Jan 4, 2019

@icefox0801's Materialize Autocomplete is not the same as Materialize Autocomplete. @tayhimself

@drewrwilson
Copy link

Any update? Having this same issue

@pistell
Copy link

pistell commented Feb 16, 2019

This is still persisting

@devrafalko
Copy link

I encountered the same problem with the select element and M.FormSelect.init() but eventually I have figured out that my SELECT element must be appended to the DOM before I call M.FormSelect.init(), then this error is not thrown.

@anshulkatta
Copy link

anshulkatta commented Mar 25, 2019

Only solution as of now

Solution is to add input field class div always in autocomplete to remove this error ...even in the latest version

<div class="input-field">
		<input type="text" id="autocomplete-input" placeholder="Search..." onchange="performSearch();"
			class="autocomplete search_term red-text"
			style="border-radius: 25px; padding: 10px; border: 2px solid crimson;">
</div>

Make sure your input type text is inside input-field div

@luisolf
Copy link

luisolf commented Mar 29, 2019

People still making a lot of confusion. This git issue is for Icefox's Autocomplete, not Materialize's default Autocomplete, the input-field thing is for the standard materialize autocomplete.

Icefox's one stopped working on Materialize 1.0, due to the changes in dropdown object, but it is still better, has multiple item selection support, and those willing to make it work I point the way above, just follow the instructions I wrote.

@sajadghobadi
Copy link

sajadghobadi commented May 19, 2019

use id selector instead class selector. for example call dropdown like this :
html:

<a class='dropdown-trigger' id="dropdowner" href='#' data-target='dropdown1'>Drop Me!</a> <ul id='dropdown1' class='dropdown-content'> <li><a href="#!">one</a></li> <li><a href="#!">two</a></li> <li class="divider" tabindex="-1"></li> <li><a href="#!">three</a></li> <li><a href="#!"><i class="material-icons">view_module</i>four</a></li> <li><a href="#!"><i class="material-icons">cloud</i>five</a></li> </ul>

js :
$('#dropdowner').dropdown();

@Lagicrus
Copy link

Came across this looking for answers. Wasn't able to find much so I dug into it a little further and noticed that it appends the ul dropdown to the first parent element of .input-field. In my case I didn't have that element.

After I added that class, all good. My html below:

<div class="col s4 center search input-field"> <!-- added .input-field -->
    <input class="autocomplete" type="text" id="autocomplete-input" placeholder="Search" />
</div>

Thanks for the fix man :D

@SmythyCosta
Copy link

@avidus3r , Thank you, you saved my life.

@lozfroston
Copy link

@avidus3r gave me the solution to this problem too, adding the class to the parent element of the input.

Thank you !!!

@TorvaldsDB
Copy link

Materialize souce code

_this37.$inputField = _this37.$el.closest('.input-field');

so you have have the class input-field, follow the official document

  <div class="row">
    <div class="col s12">
      <div class="row">
        <div class="input-field col s12">
          <i class="material-icons prefix">textsms</i>
          <input type="text" id="autocomplete-input" class="autocomplete">
          <label for="autocomplete-input">Autocomplete</label>
        </div>
      </div>
    </div>
  </div>

image

However, in the prior version 0.1.0.0.2 the logic is:

image

As a word, if you are lucky to meet the problem. You have to add the class input-field in the input parent element(in my case , the parent element is div).

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

No branches or pull requests