Pergunta

Em Optimizely, eu estou tentando fazer algumas básico de eventos de clique.Eu sei que Optimizely é só no jquery 1.6, assim, o uso on(), off() para os eventos é inútil.Para certificar-se, eu estou usando a mais básica manipulador de eventos click(function(){ ... }));, mas mesmo isso não está funcionando.Foi-me dito para utilizar a janela.$ mas no click() esta técnica não funcionará.É o jquery no Optimizely diferente?

Eu sei que há algum tipo de problema entre Optimizely e jQuery, mas por favor, alguém pode me derramar alguma luz sobre isso?

JS snippett:

(function(window.$) {

  window.$.fn.tabbs = function(options) {
    var settings = {
            dir: 'top',
            trigger: 'a',
            target: '.tab-section',
            selected: 'selected'
        },
        html = $('html');

    window.alert('jquery object: ' + window.$);

    if (html.hasClass('no-js')) {
        html.removeClass('no-js').addClass('js');
    } else {
        html.addClass('js');
    }

    var classAction = function(obj, action, cls) {
        window.$(obj)[action](cls);
    };

    window.$.extend(settings, options);

    return this.each(function() {
        var tabs = window.$(this),
            tab = tabs.find(settings.trigger),
            tabSection = window.$(settings.target),
            tabsSystemContainer = tabs.closest('div');

        switch(settings.dir) {
            case 'left':
                tabsSystemContainer.removeClass(settings.dir || 'top').addClass('left' || settings.dir);
                break;
            default:
                tabsSystemContainer.removeClass('left' || settings.dir).addClass(settings.dir || 'top');
        }
        //this where I'm having problems
        tab.click(function(e) {
            var self = window.$(this);

            e.preventDefault();

            window.alert('Hello, inside tab click event...');
        });
    });
  };
}(window.jQuery));

window.$('.tabs').tabbs();

Muitos Thnaks

Foi útil?

Solução

Você tem um erro de sintaxe na linha 1:

(function(window.$) {

deve ler

(function($) {

Você pode usar qualquer jQuery (>= 1.6) que você gosta:basta inserir o que deseja, e em Optimizely Configurações -> jQuery Definições, seleccione "não incluir o jQuery no projeto de código", e as coisas funcionam bem.Certifique-se de que você incluir sua própria jQuery antes de a Optimizely tag de script, no entanto.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top