可以´不要将form与qtip2一起使用.(活动不会激活.)

Can´t use form with qtip2. (Events won´t activate.)

本文关键字:活动 一起 激活 #180 可以 form qtip2      更新时间:2023-09-26

我正在尝试使用qtip并创建一个显示在qtip中的嵌入式表单。当我试图创建一个提交事件到我的表单时,什么都不会发生。我使用的是jquery 1.7和最新的qtip版本。

我试着使用http://craigsworks.com/projects/qtip2/demos/但他们的演示对我不起作用。请看一下我的代码,告诉我是否做错了什么。

提前感谢!

$("#addNews").qtip({
    position: {
       corner: {
          target: 'bottomMiddle',
          tooltip: 'topMiddle'
       },
       adjust: { x: 0, y: 0 }
    },
    show: {
        when: { event: 'click' },
        solo: true
    },
    hide: {
        fixed: true,
        when: { event: 'unfocus' }
    },
    content: { 
        text: '<form id="frmAddNews"><div class="inputWrap left"><div class="label">Rubrik</div><input type="text" id="" name="" class="inputText" value="" /></div><div class="inputWrap left"><div class="labelTextarea">Meddelande</div><textarea id="" name="" class="inputTextarea" value=""></textarea></div><div class="submit_container"><input type="submit" value="Lägg till nyhet" /></div><div style="clear:both"></div></form>',
    },
    style: {
        border: {
            width: 5,
            radius: 2,
            color: '#e1e1e1'
        },
        width: 350,
        background: '#FFF',
        padding: 15,
        tip: true, // Give it a speech bubble tip with automatic corner detection
        name: 'cream' // Style it according to the preset 'cream' style
    },
    events: {
       render: function(event, api) {
             $('form', this).bind('submit', function(event) {
                 event.preventDefault();
                 console.log("hej");
             });
        }
    },
});

我玩得很快,如果我将工具提示设置为模式显示,我就能让它发挥作用。

即将您的show选项对象设置为:

show: {
     event: 'click', // Show it on click...
     modal: {
        on: true,
        // Don't let users exit the modal in any way
        blur: false, escape: false
     }
},

我用来玩的jsFiddle。