• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Swiper only works on first update...

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 1 Posters 1.9k Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    mortenbirkelund
    last edited by Mar 1, 2017, 5:38 PM

    I am trying to add a swiper to the official rss news module, but I am having some problems. Whenever i open the page, the slider only works, the first time the getDom function is called. Once the rss feed is fetched and ready, the getDom function is called again, but this time the swiper doesnt work.

    I am using this swiper http://idangero.us/swiper/demos/
    and i am initating the swiper by creating a swiper object and passing it the class for the swiper div.

    	// Override dom generator.
    	getDom: function() {
    		if (this.newsItems.length > 0){
    			var swiper = new Swiper('.swiper-container');		
    			var container = document.createElement("div");
    			container.className = "swiper-container";
    				
    			var wrapper = document.createElement("div");
    			wrapper.className = "swiper-wrapper";
    
    ...... (more code ......
    
    return container;
    

    I cant figure out why the swiper only works the first time the getDom function is called. Any suggestions?

    1 Reply Last reply Reply Quote 0
    • M Offline
      mortenbirkelund
      last edited by Mar 3, 2017, 6:18 AM

      If anybody would be interested in trying to help solving it, then here is a link.

      https://github.com/mortenbirkelund/MMMT-Newsfeed

      Notices that if you uncomment the lines from 92-113, then the swiper is applied correctly.
      https://github.com/mortenbirkelund/MMMT-Newsfeed/blob/master/MMMT-Newsfeed.js

      But for some reason it doesnt work when i apply the same coding to the rest of the getDom function…

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        2/2
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy