Skip to content

Commit

Permalink
Merge pull request #120 from opencomponents/pass-element-to-model
Browse files Browse the repository at this point in the history
pass element to model
  • Loading branch information
ricardo-devis-agullo authored Oct 7, 2024
2 parents 461fde7 + ab1d362 commit de33f8a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/oc-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ var oc = oc || {};
}

oc.renderByHref(
{ href: attr('href'), id: attr('id') },
{ href: attr('href'), id: attr('id'), element: $component[0] },
function (err, data) {
if (err || !data) {
attr(dataRenderingAttribute, false);
Expand Down Expand Up @@ -495,7 +495,8 @@ var oc = oc || {};
callback = callback || retryNumberOrCallback;
var retryNumber = hrefOrOptions.retryNumber || +retryNumberOrCallback || 0,
href = hrefOrOptions.href || hrefOrOptions,
id = hrefOrOptions.id || Math.floor(Math.random() * 9999999999);
id = hrefOrOptions.id || Math.floor(Math.random() * 9999999999),
element = hrefOrOptions.element;

oc.ready(function () {
if (!href) {
Expand All @@ -516,6 +517,7 @@ var oc = oc || {};
success: function (apiResponse) {
var template = apiResponse.template;
apiResponse.data.id = id;
apiResponse.data.element = element;
oc.render(template, apiResponse.data, function (err, html) {
if (err) {
callback(
Expand All @@ -542,7 +544,15 @@ var oc = oc || {};
retry(
href,
function (requestNumber) {
oc.renderByHref(href, requestNumber, callback);
oc.renderByHref(
{
href: href,
retryNumber: requestNumber,
id: id,
element: element
},
callback
);
},
function () {
callback(interpolate(MESSAGES_ERRORS_RETRY_FAILED, href));
Expand Down

0 comments on commit de33f8a

Please sign in to comment.