0
<div class="btn-group">
                <button type="button" class="btn btn-sm btn-success btn-flat dropdown-toggle" data-toggle="dropdown">
                    Action <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="menu">
                    <li><a id="action" class="a" href="#action" data-index="100" data-toggle="done">Done</a></li>
                    <li><a id="action" class="a" href="#action" data-index="100" data-toggle="processing">Processing</a></li>
                    <li><a id="action" class="a" href="#action" data-index="100" data-toggle="error">Error</a></li>
                </ul>
            </div>
            <script>
$( "#action" ).on("click", "a.a", function(){

        //alert('working');
        var id = $(this).data('index');
        var status = $(this).data('toggle');

        var dataString = 'id=' + id + '&status=' + status;
        $.ajax({
            type: "POST",
            url: "status.php",
            data: dataString,
            cache: false,
            success: function (result) {
                $("#" + id + " td:eq(10) span").text(status);
                $("#" + id + " td:eq(10) span").removeClass();
                $("#" + id + " td:eq(10) span").addClass('bg-' + status);
            }
        });

    });

    </script>

dymanic button not working on click event.tried with live and delegate.but not working

Edited by arafath077

2
Contributors
1
Reply
15
Views
2 Years
Discussion Span
Last Post by pritaeas
1

Instead of

$("#action").on("click", "a.a", function() {

try using:

$("ul.dropdown-menu").on("click", "li > a.a", function() {

Side note: id should be unique, so it would be better to use class="action"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.