-1

i have a trouble with content script.

When oi run it with breakpoint its work fine, but without breakpoint not working properly. $(this).html(a.farewell); not update DOM.

My manifest contain "run_at": "document_end"

$(function () {
        $(document).ready(function () {
            console.log("ready!");
            var a = "1";
            var rows = $("tr.row");

            rows.each(function (i) {
                var id = $(this).attr("data-bull-id");
                chrome.runtime.sendMessage({ getStorage: id }, function (response) {
                    a = response;
                    console.log(response.farewell);
                    $(this).html(a.farewell);
                });


               // this.innerHTML = a.test;

            });


            console.log("ready2!");
        });


    });
Actimele
  • 486
  • 7
  • 22

1 Answers1

-1

i, I am actually not sure what $(this) inside sendMessage callback is. If you are trying to access the individual raw, I would assign $(this) to variable outside that callback.

By this comment help me, because it was mistake in $(this), "this" is reference to message but not to element.

Actimele
  • 486
  • 7
  • 22
  • 1
    Can you explain why you copied a comment by someone else verbatim as an answer? If it helped you, show how. As is, this is a very poor answer. – Xan Apr 26 '15 at 13:44