Using Javascript on Ruby on rails and editing the code
I am trying to modify a code in Javascript. My application is written is Ruby rails and Javascript. It is run in Heroku. I have been modifiying everything in Notepadd++, then I saved it, push it into heroku and then I see the results.
The problem comes when I want to change something in Javascript. I have been making changes in a file called quote.js but when I change something, nothing happens. Below you can see the code I am trying to change. I this case I am just trying to take out a column called items from the labour summary table, I removed it from the variable dest and I put it in comments in labour summary.
It seems that the changes I make here have not any effect on the whole application. Am I modifying the wrong file?
Is this the right way to modify the javascript code in Ruby rails?
Thanks.
var labour_summary = $(labour_line_items).inject({}, function(sum){
var key = this.pieceIdentifier();
var added = this.pieceSummary();
if(typeof sum[key] == 'undefined') {
// New material in summary
sum[key] = added;
} else {
// Add quantity to summary
sum[key].hours += added.hours;
sum[key].cost += added.cost;
//sum[key].item += ", " + added.item;
}
return sum;
});
var dest = this.labour_summary_table;
$("tr:gt(0)", dest).remove();
$.each(labour_summary, function() {
dest.append("<tr><td>" + [$.round_two(this.hours), $.dollars(this.hourly_rate), $.dollars(this.cost)].join("</td><td>") + "</td></tr>");
});
},
updateCustomSummary: function(e) {
var custom_line_items = this.activeQuoteItems().inject([], function(is) {
return $.merge(is, $(this).obj().activeCustomLineItems().get()); // grab this quote items labour line items
}).collect( function() {
return $(this).obj(); // extend the array and collect the labour line item objects
});
var custom_summary = $(custom_line_items).inject({}, fun开发者_如何学编程ction(sum){
var key = this.pieceIdentifier();
var added = this.pieceSummary();
if(typeof sum[key] == 'undefined') {
// New material in summary
sum[key] = added;
} else {
// Add quantity to summary
sum[key].quantity += added.quantity;
sum[key].cost += added.cost;
//sum[key].item += ", " + added.item;
}
return sum;
});
var dest = this.custom_summary_table;
$("tr:gt(0)", dest).remove();
$.each(custom_summary, function() {
dest.append("<tr><td>" + [this.customName, this.quantity, $.dollars(this.costPerPiece), $.dollars(this.cost), this.item].join("</td><td>") + "</td></tr>");
});
}
});
Check if you are including the javascript file quote.js on the page you are trying to load.(Use firebug addon for firefox under net tab or script tab to check if the file is loaded or not). You need to include javascript in your layout.
精彩评论