Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafiahmedd/993bdedac95e337bd19038ff47aa3a11 to your computer and use it in GitHub Desktop.
Save rafiahmedd/993bdedac95e337bd19038ff47aa3a11 to your computer and use it in GitHub Desktop.
Add $ sign to Ninja Tables price columns & No Price text to blank fields
const className = "price_format";
function addSign(){
let val = parseInt(jQuery("td."+className).text());
let value = $("td."+className).html();
if(value.length<1){
jQuery("td."+className).html('No Price');
}
else if($("td."+className).is(':empty')){
jQuery("td."+className).html('No Price');
}
else{
if( jQuery.isNumeric(val) ){
jQuery("td."+className).prepend('<span>$</span>');
}
}
jQuery("td."+className+" span:not(:first-child)").remove();
}
addSign();
$table.on('after.ft.paging', function() {
addSign();
});
$table.on("after.ft.filtering", function() {
addSign();
});
$table.on('click', function() {
addSign();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment