Materialize: Options passed to the dropdown are not being accounted for.

Created on 26 Jul 2016  Â·  10Comments  Â·  Source: Dogfalo/materialize

The options passed to the dropdown are being overwritten by the defaults because the options parameter and the variable in the "this.each" function are both named "options." This change happened in this commit:

https://github.com/Dogfalo/materialize/commit/51f3b11b3cf8a042a5be709e4c2bd5a7e9d34c4a
The easiest way to fix this is to change the "options" parameter to "_options."

I'll submit a PR for this request.

All 10 comments

I was just looking for an answer on why after version upgrade my dropdown stopped working on hover 😄

Damn!, I was going crazy here 'cuz the same reason :stuck_out_tongue:, after upgrade my dropdowns ignored whatever the option says. Will be good to have this PR as soon as possible, for the ones like me, that are using bower :wink: as package manager

Fixed in 2b32ca4.

Thanks for catching this!

@acburst, no problem. : ) Glad it was an easy fix.

Still having problems with options when creating dropdowns dynamically (e.x. belowOrigin = true, it's appearing hover the button not matter what).. I'm using Materialize with AngularJS, and I have a directive to initialize/trigger the drop down element functionality, passing the options as attributes.. Already try belowOrigin and beloworigin.. neither of them worked :disappointed:

<a class="drop-down btn" data-activates="app-languages"
    data-item-alignment="right" data-constrain-width="true" data-below-origin="true">
( function () {
    'use strict';

    angular
        .module( 'app.common' )
        .directive( 'dropDown', dropDownFunc );

    dropDownFunc.$inject = [ '$document' ];

    /* @ngInject */
    function dropDownFunc( $document ) {
        var directive = {
            restrict: 'C',
            link: linkFunc,
        };

        return directive;

        function linkFunc( scope, elem, attr ) {
            $document.ready( function () {
                elem.dropdown( {
                    alignment: attr.itemAlignment,
                    belowOrigin: attr.belowOrigin,
                    constrain_width: attr.constrainWidth,
                    hover: false
                } );
            } );
        }
    }
} )();

Instead, if I use:

data-beloworigin="true"

as the doc explain, and comment in the directive:

elem.dropdown( {
    alignment: attr.itemAlignment,
    //belowOrigin: attr.belowOrigin,
    constrain_width: attr.constrainWidth,
    hover: false
} );

works as expected!.. why isn't working passing the options as attribute values?? Any idea?? :confused:

This is only on master and isn't in the latest release. Sorry about that

We changed the version number in the bower.json to the URL for master until a new release is built:

"materialize": "https://github.com/Dogfalo/materialize.git#master",

the problem still occur with a NPM install. Fix seems to not be pushed to NPM.
To fix it, i have copy/paste the dropdown.js file from Git to my node_modules/materialize-css/js, then go to node_modules/materialize-css, then npm install, then grunt release, to generate the new materialize.js in the dist folder.
Probably not the better way to do it, but work on my local dev env.
Any idea to have a better fix to be pushed on prod ?

I prefer a patch - after module is loaded I overwrite the function with the
fixed code.

On 30 October 2016 at 10:00, patrice [email protected] wrote:

the problem still occur with a NPM install. Fix seems to not be pushed to
NPM.
To fix it, i have copy/paste the dropdown.js file from Git to my
node_modules/materialize-css/js, then go to node_modules/materialize-css,
then npm install, then grunt release, to generate the new materialize.js in
the dist folder.
Probably not the better way to do it, but work on my local dev env.
Any idea to have a better fix to be pushed on prod ?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Dogfalo/materialize/issues/3417#issuecomment-257121047,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADimvJjv9eubpUi2U-lY2GIbSUElCMU9ks5q49AqgaJpZM4JVl_N
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artur99 picture artur99  Â·  3Comments

PhillippOhlandt picture PhillippOhlandt  Â·  3Comments

lpgeiger picture lpgeiger  Â·  3Comments

cope picture cope  Â·  3Comments

heshamelmasry77 picture heshamelmasry77  Â·  3Comments