Galupo
Galupo

Reputation: 1

Jquery Tooltipster - access DOM after ajax

I have some troubles with the jquery plugin Tooltipster and ajax :

  1. I click on a link to launch tooltipster -> ok
  2. I get a form with ajax -> ok
  3. I would like to interact with my form's input -> not ok

Here is my code :

    var id = $(this).attr("scope");
    var tp = $(this).attr("id");
    $(this).tooltipster({
                interactive:true,
                contentAsHTML: true,
                position: 'top',
                content: 'Chargement...',
                delay: '0',
                speed: 150,
                trigger: 'click'
                functionBefore: function(origin, continueTooltip) {
                    continueTooltip();      
                    $.ajax({
                        type: 'GET',
                        url: '/ajax/platform.php',
                        data: {variable1: variable1, variable2: variable2},
                        success: function(data) {
                            origin.tooltipster('content', data).data('ajax', 'cached');
                        }
                    });
                },
                theme: 'tooltipster-shadow'
            });
    });

Ajax send me html like :

<input type="text" name="input1" id="input1">

How can I do to interact with #input1 with jquery ?

Upvotes: -1

Views: 45

Answers (1)

Galupo
Galupo

Reputation: 1

It works like that :

var id = $(this).attr("scope");
var tp = $(this).attr("id");
$(this).tooltipster({
            interactive:true,
            contentAsHTML: true,
            position: 'top',
            content: 'Chargement...',
            delay: '0',
            speed: 150,
            trigger: 'click'
            functionBefore: function(origin, continueTooltip) {
                continueTooltip();      
                $.ajax({
                    type: 'GET',
                    url: '/ajax/platform.php',
                    data: {variable1: variable1, variable2: variable2},
                    success: function(data) {
                        origin.tooltipster('content', data).data('ajax', 'cached');
                        $("#input1").click(function(d) {
                                d.preventDefault();
                                alert("It works !");
                        });
                    }
                });
            },
            theme: 'tooltipster-shadow'
        });
});

Upvotes: 0

Related Questions