Redirect to another view not working
Redirect to another view not working
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
**Case 1
**
$(document).ready(function (e) {
if (id == 'Yes') {
e.preventDefault();
window.location.href = '/Home/Yes/' + parseInt($(this).attr('data-field'));
}
else if (id == 'No;
window.location.href = '/Home/No/' + parseInt($(this).attr('data-field'));
}
});
**Case 2 **
$(document).ready(function (e) {
if (id == 'Yes') {
e.preventDefault();
window.location.href = '/Home/Yes/' + parseInt($(this).attr('data-field'));
}
else if (id == 'No;
window.location.href = '/Home/No/' + parseInt($(this).attr('data-field'));
}
alert(id + ' doc ready You clicked on button ' + datafie);
});
case 1 does not work, but case 2 does..How ever i want to get rid of alert message and redirect smoothly.
Replies
That doesn't seem to be a Datatables related question. You are probably better off asking this on StackOverflow. Thanks.
Absolutely not a DataTables issue.
However, in both cases your "else if (id == 'No;" condition is missing some brackets.
ist is hold on im updating my sample code
http://live.datatables.net/dasejuca/5/edit
first row redirects, however second rows never redirects..
The second button does more than nothing - you see the alert. The reason it doesn't redirect is due to the if statements:
The id of the second button is
2so it won't match any of the if statements.Instead of using the
idI would look assigning each type of button the same name or value. In the click event use the name or value to determine where to redirect. Take a look on Stack Overflow to see which option will work best for your solution.Kevin
Thanks!!
worked now ..i guess it was syntax