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

this.stickyAlerts is undefined #128

Open
ScopesCodez opened this issue Jun 23, 2022 · 1 comment
Open

this.stickyAlerts is undefined #128

ScopesCodez opened this issue Jun 23, 2022 · 1 comment
Labels
v1 Version 1.x.x

Comments

@ScopesCodez
Copy link

I have this simple code:

halfmoon.initStickyAlert({title: 'Publishing...', message: '<i class="fas fa-spinner fa-spin"></i> Your post is being published, please wait..', type: 'alert-secondary', timeShown: 1500})

triggered when a form is being submitted, here's the full code:

$("#post-form").submit(function (e) {
                    e.preventDefault();
                    $.ajax({
                        url: '/post',
                        type: 'GET',
                        beforeSend: function () {
                            $('#settings-form').find('button').attr('disabled', true);
                            halfmoon.initStickyAlert({title: 'Publishing...', message: '<i class="fas fa-spinner fa-spin"></i> Your post is being published, please wait..', type: 'alert-secondary', timeShown: 1500})
                        },
                        data: {
                            content: content
                        },
                        success: function () {
                            $('#settings-form').find('button').attr('disabled', false);
                            $('#content').val('');
                            $('#posts').unload()
                        },
                        error: function () {
                            $('#settings-form').find('button').attr('disabled', false);
                        }

                    });
                });

I keep getting this error whenever trying to trigger the function.
error

Meanwhile, I have it working in another page. Here's the code:

$("#settings-form").submit(function(e) {
                e.preventDefault();
                $.ajax({
                    type: 'GET',
                    url: '/update-profile',
                    beforeSend: function() {
                        $('#settings-form').find('button').attr('disabled', true);
                        halfmoon.initStickyAlert({
                            title: 'Saving...',
                            content: '<i class="fas fa-spinner fa-spin"></i> Saving changes...',
                            type: 'alert-secondary',
                            timeShown: 1500
                        });
                    },
                    data: $('#settings-form').serialize(),
                    success: function(data) {
                        window.scrollTo(0, 0);
                        halfmoon.initStickyAlert({
                            content: "Profile has been updated successfully.",
                            title: "Changes Saved!",
                            alertType: "alert-success",
                            fillType: "",
                            hasDismissButton: false,
                            timeShown: 3000
                        })
                        $('#sidebar-username').html($('input[name=username]').val());
                        $('#settings-form').find('button').attr('disabled', false);
                    },
                    error: function(data) {
                        console.log("Error")
                        console.log(data)
                        window.scrollTo(0, 0);
                        halfmoon.initStickyAlert({
                            content: "There was an error updating your profile. Please try again.",
                            title: "Error!",
                            alertType: "alert-danger",
                            fillType: "",
                            hasDismissButton: false,
                            timeShown: 3000
                        })
                        $('#settings-form').find('button').attr('disabled', false);
                    },
                    
                });
            });

I have halfmoon.js imported in a headers file, and this headers file is imported in all my pages' files.

@JKoblitz
Copy link

Have you added the sticky-alerts container to your page-wrapper?

<div class="sticky-alerts"></div>

Documented here.

@halfmoonui halfmoonui added the v1 Version 1.x.x label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1 Version 1.x.x
Projects
None yet
Development

No branches or pull requests

3 participants