o.o
o.o

Reputation: 3751

Call same function in jquery after modal shows up

I'm using bootstrap modals to show the contents in my divs when a text is clicked (surrounded by <span>).

I call it by $(#div_to_show").modal() whenever you click the text inside a span tag. modal() is part of the bootstrap modal javascript.

My span uses the class someClass. I use

function update() 
{
    ('.someClass').click(function() {
        var atr = $(this).attr("atr");

        $.get("../Folder/getFile?atr="atr, function(data) {
            json=JSON.parse(data);

            if(typeof(json.error) == "undefined") {
                var foobar = json.foo.replace(/_/g, '"');
                bar("#div_to_show", foobar);
                $("#div_to_show").modal();
            }
        });

        return false;
    });
}

I could add update(); after $(#div_to_show").modal(); but that causes it to go in an infinite loop even though the modal showed up and the span is not being clicked.

My question is how can I call the function update() whenever you click the text which is wrapped around span?

Upvotes: 0

Views: 1050

Answers (1)

Leo
Leo

Reputation: 675

Try this:

$('.someClass').on('click', function() {
    update();
});

function update()
{
    $("#div_to_show").modal();
}

Upvotes: 3

Related Questions