Code Monkey home page Code Monkey logo

Comments (4)

genadis avatar genadis commented on August 17, 2024

Please Notice, Aurelia has an issue with using for attribute on non <label>.
For menu element you can use data-mdl-for attribute instead of for. But for tooltips MDL didn't implement it, so if you use binding/string interpolation, until the Aurelia bug is fixed, use label as in the example below.

Allow me to suggest wrapping it in custom element.
I'm successfully using it as:

// button-icon.html
<template bindable="click" bindable="tooltipEn">
  <div click.delegate="clickHandle($event)" mdl="button" class="mdl-js-ripple-effect mdl-button--icon" id="button-${id}">
    <i class="material-icons md-dark">
      <template replaceable part="icon">&#xE913;</template> <!--touch_app-->
    </i>
  </div>

  <label if.bind="tooltipEn" mdl="tooltip" class="mdl-tooltip--large" for="button-${id}">
    <template replaceable part="tooltip">click</template>
  </label>
</template>
// button-icon.js
import {bindable, customElement} from 'aurelia-framework';
import {guid} from '../util';

@customElement('button-icon')
export class ButtonIcon {
  id = guid();      // generate unique guid
  @bindable tooltipEn = false;
  @bindable click;

  clickHandle(e) {
    if (typeof this.click === 'function') {
      this.click({event: e});
    }
  }
}

Usage:

        <button-icon click.call="myClickAction()" tooltip-en.one-way="enableTooltip">
          <template replace-part="icon">&#xE879;</template> <!--exit_to_app-->
          <template replace-part="tooltip">This is my tool tip</template>
        </button-icon>

I haven't used mdl-tooltip--right yet...

from aurelia-mdl.

egeland avatar egeland commented on August 17, 2024

Interesting workaround!
A good use for template replace-part - I (being a n00b) was wondering where that would be needed.
Thanks for your answer - I'll see how I go with that! 😃

from aurelia-mdl.

egeland avatar egeland commented on August 17, 2024

I tried just changing my tooltip from a div to a label and it's happy now, so my use case is:

<span class="mdl-list__item-secondary-action">
  <button id="edit_${$index}" mdl="button" class="mdl-button--icon mdl-button--colored">
    <i class="mdi mdi-pencil"></i>
  </button>
  <label mdl="tooltip" class="mdl-tooltip--large" for="edit_${$index}">
    Edit Task
  </label>
</span>

And yeah, only --large works for me..

from aurelia-mdl.

timfish avatar timfish commented on August 17, 2024

Just hit this and thought I was going crazy!

from aurelia-mdl.

Related Issues (13)

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.