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

Dynamically rendered templates/regions need auto-upgrading. #3

Open
Zodiase opened this issue Jul 8, 2015 · 7 comments
Open

Dynamically rendered templates/regions need auto-upgrading. #3

Zodiase opened this issue Jul 8, 2015 · 7 comments

Comments

@Zodiase
Copy link
Owner

Zodiase commented Jul 8, 2015

I added this demo to show how dynamically rendered DOM content are not upgraded.

I need to find a way to do batch upgrading when changes to the DOM are detected.

@Zodiase
Copy link
Owner Author

Zodiase commented Jul 9, 2015

Well, currently the workaround is, whenever you expect DOM has been changed, call

componentHandler.upgradeAllRegistered();

or, better if you know exactly what's new, use componentHandler.upgradeElement.

However it's important to only upgrade when you know that the changes are effective.
For example, the following code won't work.

// Using Iron:Router
route.render('home');
componentHandler.upgradeAllRegistered(); // Won't work because the rendering job is not done yet.

@Zodiase
Copy link
Owner Author

Zodiase commented Jul 9, 2015

Commit 7b763fd added a patch for calling auto-upgrade whenever a change is detected in DOM.

It uses MutationObserver which is not compatible with old browsers. If MutationObserver is not available, it falls back to the old approach, which still has bugs.

I'm not satisfied with the current implementation's efficiency; calling componentHandler.upgradeAllRegistered() scans the whole DOM which is not necessary. I'm new to MutationObserver so I'll see if I could narrow the scan down.

@ojenksdev
Copy link

Having issues with updating the DOM automatically using FlowRouter. Seems to break every time. Should componentHandler.upgradeAllRegistered() be added after each route?

ie:

FlowRouter.route('/', {
    action: function() {
      BlazeLayout.render("mainLayout", {header: "homeHeader", content: "homeContent"});
      componentHandler.upgradeAllRegistered();  //<-- add this here? 
    }
});

First time implementing mdl with meteor, so any advice would help!

Thanks!

@Zodiase
Copy link
Owner Author

Zodiase commented Aug 13, 2015

@ojenksdev Thanks for reporting this. Could you fire a new issue for this? This issue is not intended to cover every upgrading issues but only the generic ones in Meteor. In the new issue, it would also be very helpful to provide the steps to reproduce the errors you are experiencing and what packages and what versions you are using.

@a-vasyliev
Copy link

I guess I have same issue. I have table with data, it gets updated "on the fly" via live query, but new table records appears without checkboxes (added by JS part of MDL).. How to force it to redraw?

@Zodiase
Copy link
Owner Author

Zodiase commented Dec 31, 2015

Hi @a-vasyliev if you are talking about the table row checkboxes, check out issue #10.

@a-vasyliev
Copy link

@Zodiase Thank you!

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

No branches or pull requests

3 participants