If an HTML attribute value is supposed to contain a space, then you have to use quotation marks to delimit the value.
Pay attention to the syntax highlight here:
<span foo=bar baz ></span>
This is an attribute foo with value "bar" and a boolean attribute baz.
On the other hand, this
<span foo="bar baz"></span>
is an attribute foo with value "bar baz". Notice how baz is highlighted differently?
To fix your issue, either put quotation marks around the value of onclick, or better, use a different way to bind the event handler.
"<button … onclick='editRecords(\'" + partId + "\')'> …"?