Skip to content

Commit

Permalink
Use jQuery apis for handling before and after insertion modes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaybhargavb committed Mar 27, 2018
1 parent a81010e commit 4269c0f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
29 changes: 12 additions & 17 deletions dist/jquery.unobtrusive-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,18 @@
var top;

switch (mode) {
case "BEFORE":
top = update.firstChild;
$("<div />").html(data).contents().each(function () {
update.insertBefore(this, top);
});
break;
case "AFTER":
$("<div />").html(data).contents().each(function () {
update.appendChild(this);
});
break;
case "REPLACE-WITH":
$(update).replaceWith(data);
break;
default:
$(update).html(data);
break;
case "BEFORE":
$(update).prepend(data);
break;
case "AFTER":
$(update).append(data);
break;
case "REPLACE-WITH":
$(update).replaceWith(data);
break;
default:
$(update).html(data);
break;
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.unobtrusive-ajax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 12 additions & 17 deletions src/jquery.unobtrusive-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,18 @@
var top;

switch (mode) {
case "BEFORE":
top = update.firstChild;
$("<div />").html(data).contents().each(function () {
update.insertBefore(this, top);
});
break;
case "AFTER":
$("<div />").html(data).contents().each(function () {
update.appendChild(this);
});
break;
case "REPLACE-WITH":
$(update).replaceWith(data);
break;
default:
$(update).html(data);
break;
case "BEFORE":
$(update).prepend(data);
break;
case "AFTER":
$(update).append(data);
break;
case "REPLACE-WITH":
$(update).replaceWith(data);
break;
default:
$(update).html(data);
break;
}
});
}
Expand Down

0 comments on commit 4269c0f

Please sign in to comment.