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

Where to write the <script/> required to run "lastRowFixedOnly" in Toolbar of mdc? #64

Open
prakharrke opened this issue Dec 6, 2017 · 1 comment

Comments

@prakharrke
Copy link

prakharrke commented Dec 6, 2017

I am stuck as to lastRowFixedOnly requires a javascript to be run in order to make it work. Where should I write it? While defining the Component ToolBar, I wrote it in componentDidMount method but it gives me an error of mdc is not defined.

import React from "react";
import Toolbar from "react-mdc-web/lib/Toolbar/Toolbar";
import ToolbarRow from "react-mdc-web/lib/Toolbar/ToolbarRow";
import ToolbarSection from "react-mdc-web/lib/Toolbar/ToolbarSection";
import ToolbarTitle from "react-mdc-web/lib/Toolbar/ToolbarTitle";

export class Header extends React.Component{
  componentDidMount() {
    const s = document.createElement("script");
    s.type = "text/javascript";
    s.async = true;
    s.innerHTML = "var toolbar = mdc.toolbar.MDCToolbar.attachTo(document.querySelector('.mdc-toolbar')); toolbar.fixedAdjustElement = document.querySelector('.mdc-toolbar-fixed-adjust');";
  document.body.appendChild(s);
  }
render(){

return(

  <Toolbar fixed fixedLastRowOnly>
  <ToolbarRow>
  <ToolbarSection>
  <h1>This is row 1</h1>
  </ToolbarSection>
</ToolbarRow>
 <ToolbarRow>
    <ToolbarSection>
    <ToolbarTitle>Title</ToolbarTitle>
   </ToolbarSection>
    </ToolbarRow>
    <ToolbarRow>
    <ToolbarSection>
    <ToolbarTitle>Title</ToolbarTitle>
  </ToolbarSection>
    </ToolbarRow>
  </Toolbar>
);
}
}
@kradio3
Copy link
Owner

kradio3 commented Dec 6, 2017

yes, that is exactly what i'm removing now, don't use it at the moment

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

2 participants