0

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

4
  • 1
    You cannot have multiple buttons (or elements) with the same id. Commented Jul 4, 2013 at 19:25
  • 1
    Please post HTML code and preferably on jsfiddle. Commented Jul 4, 2013 at 19:32
  • You are removing the cells and not the rows, change it to: $("#added-parcels tr").remove(); (this won't fix the main issue) Commented Jul 4, 2013 at 19:47
  • Here is the fiddle. Its seems to works but if you see the //<!-- Textbox hide values --> script is not working. Commented Jul 4, 2013 at 19:56

1 Answer 1

1

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

 $("#added-parcels button").button();
Sign up to request clarification or add additional context in comments.

2 Comments

The same applies for every jQuery UI element: stackoverflow.com/questions/3028912/…
Sweet!! Thank you and then obviously call any other custom script functions that apply to that code block as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.