Git Product home page Git Product logo

Comments (2)

imacrayon avatar imacrayon commented on May 27, 2024

Hey, thanks for reaching out. So I made a basic test in CodePen just to confirm that new components do initialize with Morph here: https://codepen.io/imacrayon/pen/JjVZMrB

I'm guessing your situation is probably a more complicated though. There's definitely edge cases where the morph algorithm breaks down, so I might need a little more info about how you're using it. Would you be able to provide a code sample that reproduces your issue?

from alpine-ajax.

jonasfeige avatar jonasfeige commented on May 27, 2024

Hey, thanks for the quick reply and sorry for being so brief in my initial description of the issue.

I've made another pen that reproduces my setup and it seems to be working as expected. Basically, I have two routes (/ and /books, where the latter is morphing an alpine component that needs to then initialize.
https://codepen.io/jonasfeige/pen/LYvBKay

I still could not get it to work in my actual project, though. The Alpine component will not initialize and therefor the hidden text will be visible on morphing. I assume it has to do with my build process (using esbuild). Maybe you have an idea?

This is my app.js:

import Alpine from 'alpinejs'
import morph from '@alpinejs/morph'
import collapse from '@alpinejs/collapse'
import ajax from '@imacrayon/alpine-ajax'

import post from './alpine/data.post'

Alpine.plugin(collapse)
Alpine.plugin(morph)
Alpine.plugin(ajax)

document.addEventListener('alpine:init', () => {
	Alpine.data('post', post)
})

Alpine.start()

And this is the (abbreviated) data.post.js:

export default () => ({
	more: false,
	toggleMore() {
		if (!this.more) {
			this.more = true
		} else {
			this.more = false
		}
	},
})

from alpine-ajax.

Related Issues (20)

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.