e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 212 forks source link

javascript e107.behaviour context #3884

Open nesjett opened 4 years ago

nesjett commented 4 years ago

I'm trying to use contexts but I can't find any example of ussage, only about settings but not context.

Someone can add some light on this?

Thank you

tgtje commented 4 years ago

Maybe here's an answer found ? #1259

nesjett commented 4 years ago

Thank you @tgtje but this is the same info that appears in the developer manual, but no example or notice about using context.

Moc commented 4 years ago

@lonalore knows most about this part of e107 :)

lonalore commented 4 years ago

e107 core will call attached behaviors when the DOM (the object representation of the HTML) is fully loaded, passing in two arguments:

You can find many exampe usages here: https://github.com/e107inc/e107/blob/master/e107_web/js/core/all.jquery.js

For example:

/**
 * Behavior to hide elements.
 *
 * @type {{attach: e107.behaviors.eHideMe.attach}}
 */
e107.behaviors.eHideMe = {
    attach: function (context, settings)
    {
        $(context).find('.e-hideme').once('e-hide-me').each(function ()
        {
            $(this).hide();
        });
    }
};