I've got a getJSON
script that should respond if a Ruby value is not nil
, but I'm not sure how to check for if not (ruby's version of) nil
through javascript. So far it looks like this:
$.getJSON("<%= xhr_document_path(document) %>", function(d) {
if (d.ok) {
$('#modal_<%= document.id %>').modal('show');
clearInterval(doc_modal_<%= document.id %>);
} else if (d.error != '') {
window.location.href = "<%= error_document_path(document) %>";
}
});
But the else if
condition is tripped when the value is nil. How do I check for not nil
here?
I've got a getJSON
script that should respond if a Ruby value is not nil
, but I'm not sure how to check for if not (ruby's version of) nil
through javascript. So far it looks like this:
$.getJSON("<%= xhr_document_path(document) %>", function(d) {
if (d.ok) {
$('#modal_<%= document.id %>').modal('show');
clearInterval(doc_modal_<%= document.id %>);
} else if (d.error != '') {
window.location.href = "<%= error_document_path(document) %>";
}
});
But the else if
condition is tripped when the value is nil. How do I check for not nil
here?
1 Answer
Reset to default 7If d
was converted from Ruby to JavaScript through JSON, then the Ruby nil
would be converted to JavaScript null
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745660364a4638797.html
评论列表(0条)