user1752532
user1752532

Reputation:

jqueryui elements not loading on button click

I am having a bit of a problem with jqueryui elements that are called from inside a script. They are not loading as jqueryui elements. I think i need to somehow call the jquery script again but i am not too sure how to go about this.

the button click code is

$("#parcels-add").click(function () {
    //remove existing table rows if there are any
    $("#added-parcels tr td").remove();
    $("#parcel").css("display", "block");
    //Add the rows
    for (var i = 0; i < numOfParcels; i++) {
       $("#added-parcels").prepend("<tr>" +
                                   "<td>" + "01" + "</td>" +
                                   "<td><input type='text' value='cm' class='package-value' /></td>" +
                                   "<td><input type='text' value='cm' class='package-value' /></td>" +
                                   "<td><input type='text' value='cm' class='package-value' /></td>" +
                                   "<td><input type='text' value='cm' class='package-value' /></td>" +
                                   "<td><button id='package-delete'>Delete</button></td>") +
                                 "</tr>";
      }
});

The button in the for loop is not displaying like the rest of the jqueryui buttons. as seen below enter image description here

It looks and acts like a normal HTML button

enter image description here

I also have a simple script to remove the text in the input text box's which is not working

Would this maybe have something to do with the ordering of the javascript files? There is no error in the chrome console but this is not working as it should.

Any help would be much appreciated.

Thanks

Upvotes: 0

Views: 69

Answers (1)

Balint Bako
Balint Bako

Reputation: 2560

Call .button() on the new buttons after the for loop.

 $("#added-parcels button").button();

Upvotes: 1

Related Questions