I have a link that when clicked should generate a PDF document and change the text of himself.
This is my JS function:
function clander(){
window.location="orders/issueBill/order_id/"+order_id;
$('#jander').replaceWith('pdf just generated');
}
The link:
<a href="#" id="jander" onClick='clander()'>click here</a>
The action:
public 开发者_运维技巧function executeIssueBill(sfWebRequest $request) {
//here is the code that generates the pdf.
}
The problem: when I click the link, it generates the pdf but the text of the link is not changed. It only changes the text if I remove the window.location...
line.
The reason of my code is here.
Any idea?
Regards
Javi
The problem is that it never gets to this part:
$('#jander').replaceWith('pdf just generated');
It redirects the user to "orders/issueBill/order_id/"+order_id
, which is a different page, so it doesn't remember state.
I guess your best bet is to pass a parameter to the new page (ie. "orders/issueBill/order_id/"+order_id+"?pdf_generated=1"
) - this way it'll know that the pdf was generated, and you can change the link accordingly.
I think it's the order of your statements in the js function. If you change the order the other way around, should work fine like so:
<script>
function clander(){
document.getElementById('jander').innerHTML = 'pdf just generated';
window.location="orders/issueBill/order_id/"+order_id;
}
</script>
<a href="#" id="jander" onClick='clander()'>click here</a>
Best, Kamran
精彩评论