question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hi

i’m new to barba but it seems to be an outstanding framework

i use several functions on my main page - they open/close popups, side menus and so on. from there i can jump to three detail views with barba - everything works fine. but coming back from a detail view to the main page again - all functions are off?

  • i load my functions together with barba view/transition controller in a single .js file outside the barba-wrapper just before closing the body tag. (-> views.js)

  • all js stuff is wrapped inside document.addEventListener("DOMContentLoaded", function() {..}

  • both pages (home & detail) use the same .js file.

  • html & js is strictly separated

  • both pages have the same dependencies (css, fonts, libraries)

  • adding the .no-barba class to the back button of the detail page and everything works as intended …

there must be something in barba i do wrong - why does it kill my functions?

thanks for your help mad

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lurukecommented, Jul 10, 2017

Hello @ZAAK-ZURICHBERLIN , Barba.js never kills your functions.

Let’s take $("#MenuTrigger").click(...) for example:

  • When you load the first page, an event listener is created for #MenuTrigger currently on your DOM.
  • When you change page with barba, the content of the next page is injected, that means that if a new #MenuTrigger is added, it won’t trigger your click function.

Use barba event newPageReady to “reattach” your events on the new DOM elements. Of course this applies just of the contents inside your barba-container.

If you want to know more on about barba.js works under the hood, you can read this article I wrote: https://www.smashingmagazine.com/2016/07/improving-user-flow-through-page-transitions/

0reactions
StudioZAAKcommented, Jul 13, 2017

aaarghh… there was a single onclick="" in my detail.html page that was breaking everything 😃 so strictly separate html & js as you anyway should do but in barba universe it seems to be mandatory. still i would appreciate a more detailed explanation of the barba event newPageReady

thank you for making barba.js - love it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to Loss Functions - DataRobot AI Cloud Blog
At its core, a loss function is incredibly simple: It's a method of evaluating how well your algorithm models your dataset. If your...
Read more >
Loss function - Wikipedia
In mathematical optimization and decision theory, a loss function or cost function is a function that maps an event or values of one...
Read more >
Loss Function Definition | DeepAI
Loss functions are used in regression when finding a line of best fit by minimizing the overall loss of all the points with...
Read more >
Loss and Loss Functions for Training Deep Learning Neural ...
Cross-entropy and mean squared error are the two main types of loss functions to use when training neural network models.
Read more >
The 7 Most Common Machine Learning Loss Functions - Built In
The loss function is a method of evaluating how well your machine learning algorithm models your featured data set. In other words, loss ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found