Git Product home page Git Product logo

Comments (7)

somewebmedia avatar somewebmedia commented on June 2, 2024 1

Just update to new v5.0.4 I just published, I actually forgot to return the main function. :)

from hc-offcanvas-nav.

somewebmedia avatar somewebmedia commented on June 2, 2024 1

Can you try this code:

// any CSS you import will output into a single css file (app.css in this case)
import '../css/app.css';
// Need jQuery? Install it with "yarn add jquery", then uncomment to import it.
import $ from 'jquery';
import 'bootstrap';
import 'noty';
import hcOffcanvasNav from 'hc-offcanvas-nav';

$(function () {
// ===========Right Sidebar============
    $('[data-toggle="offcanvas"]').on('click', function () {
        $('body').toggleClass('toggled');
    });
    // ===========Hover Nav============ 
    $('.navbar-nav li.dropdown').on('mouseenter', function () {
        $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(500);
    });
    $('.navbar-nav li.dropdown').on('mouseleave', function () {
        $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(500);
    });
    // ===========Tooltip============
    $('[data-toggle="tooltip"]').tooltip();
    // ===========Mobile Menu============
    new hcOffcanvasNav('#main-nav', {
        disableAt: false,
        customToggle: $('.toggle')[0],
        levelSpacing: 40,
        navTitle: 'MENÚ PRINCIPAL',
        labelClose: 'Cerrar',
        labelBack: 'Atrás',
        levelTitles: true,
        levelTitleAsBack: true,
        pushContent: '#container',
        insertClose: 2
    });
});

from hc-offcanvas-nav.

glavrjk avatar glavrjk commented on June 2, 2024 1

@glavrjk did you manage to get it to work?

thank you so much you solution worked for me...!
Sorry for the delay

from hc-offcanvas-nav.

somewebmedia avatar somewebmedia commented on June 2, 2024

Hey @glavrjk, in the major version 5 the lib is now dependency free, so you don't need jQuery anymore for using it, but it can still be used with it if you prefer that way (check the readme).

In order to use it as jQuery plugin, the jQuery object needs to be attached to the global window object, which is not the case if you load it with Webpack or Browserify.
Read it here: https://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack

But to save yourself the hassle just instance it like this:

import hcOffcanvasNav from 'hc-offcanvas-nav';

const Nav = new hcOffcanvasNav('#main-nav', {
    disableAt: false,
    customToggle: $('.toggle'),
    levelSpacing: 40,
    navTitle: 'MENÚ PRINCIPAL',
    labelClose: 'Cerrar',
    labelBack: 'Atrás',
    levelTitles: true,
    levelTitleAsBack: true,
    pushContent: '#container',
    insertClose: 2
});

from hc-offcanvas-nav.

glavrjk avatar glavrjk commented on June 2, 2024

ggle: $('.toggle'),

I'ts still not working man. I'm using the symfony's webpack. I took your recommendation and i deleted the $ import and it's fine but the library broken with same issue. this my complete app.js

// any CSS you import will output into a single css file (app.css in this case)
import '../css/app.css';
// Need jQuery? Install it with "yarn add jquery", then uncomment to import it.
// import $ from 'jquery';
import 'bootstrap';
import 'noty';
import * as hcOffcanvasNav  from 'hc-offcanvas-nav';

$(function () {
// ===========Right Sidebar============
    $('[data-toggle="offcanvas"]').on('click', function () {
        $('body').toggleClass('toggled');
    });
    // ===========Hover Nav============ 
    $('.navbar-nav li.dropdown').on('mouseenter', function () {
        $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(500);
    });
    $('.navbar-nav li.dropdown').on('mouseleave', function () {
        $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(500);
    });
    // ===========Tooltip============
    $('[data-toggle="tooltip"]').tooltip();
    // ===========Mobile Menu============
    $('#main-nav').hcOffcanvasNav({
        disableAt: false,
        customToggle: $('.toggle'),
        levelSpacing: 40,
        navTitle: 'MENÚ PRINCIPAL',
        labelClose: 'Cerrar',
        labelBack: 'Atrás',
        levelTitles: true,
        levelTitleAsBack: true,
        pushContent: '#container',
        insertClose: 2
    });
});

from hc-offcanvas-nav.

somewebmedia avatar somewebmedia commented on June 2, 2024

@glavrjk did you manage to get it to work?

from hc-offcanvas-nav.

somewebmedia avatar somewebmedia commented on June 2, 2024

No problem, glad I could help.

from hc-offcanvas-nav.

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.