IfnotFr / PopConfirm

A simple action confirmation plugin for jQuery based on Twitter Bootstrap Popover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

popConfirm on newly created elements

Webmoss opened this issue · comments

Hi

I am using the plugin and works great...one issue I'm having is binding to a newly created element that is created via ajax

I guess my question is How would I bind popConfirm() like the jQuery .live(), . on() or .delegate() functions for example.

Hope you can help? My functions below:

$('a.delete-skill-button').click(function() {

var url = "<?php print site_url('skill/delete'); ?>";

// Test for Empty Fields before Serializing form
var btn      = $(this),
    id       = btn.attr('id'),
    skill_id = id.split('-').pop();

$.ajax({
  type: "POST",
  dataType:'json',
  url: url,
  data:{ skill_id:skill_id },

    success: function(data){

      if(data.status === "success")
      {
        btn.parent().hide();
      }
    },
    error: function(){
      alert("Error deleting skill, Please reload page and try again!")
    }
  }
);

});

$("a.delete-skill-button").popConfirm({
title: "Remove skill", // The title of the confirm
content: "Please confirm?", // The message of the confirm
placement: "right", // The placement of the confirm (Top, Right, Bottom, Left)
container: "body", // The html container
yesBtn: "Yes",
noBtn: "No"
});

Hi :)

I dont really know how jquery plugins manage "dynamic" object (added after the dom ready). But ... PopConfirm does not manage this actually.

I think you have to call $('.selector').popConfirm(); when you add the new content (into the function adding the html ?).

No response so i close the issue :)