[
{"fname":"Foo","lname":"Pacman"},
{"fname":"Bar","lname":"Mario"},
{"fname":"Poo","lname":"Wario"}
]
Well I have JSON string in this format,
Now what I need is to convert each tuples -> {"fname":"Foo","lname":"Pacman"}
To a Person object,
for e.g. lets assume I have a case class
case class Person(fname:String,lname:String)
Now how am I to get, List<person>
If I had a JSON containing data for single tuple, then I could,
val o:Person = parse[Person](jsonString)// I am actually using Jerkson Lib
But since there are more than one tuples, how am i to parse them individually and create objects and create a list.
Replace standard javascript confirm with Twitter Bootstrap's modal - who triggered it?
I'm trying to replace the standard javascript confirm with a twitter bootstrap modal window. Everything is almost working (the modal is shown with its confirm text), but I'm stuck trying to catch the caller href, which I need to bind the "ok" button.
Here's my code (almost working example: http://jsfiddle.net/k5uDw/):
jQuery.altConfirm = function (options) {
var box = '<div class="modal fade static" id="confirm" data-backdrop="static" tabindex="-1" role="dialog">';
box += '<div class="modal-dialog">';
box += '<div class="modal-content">';
box += '<div class="modal-body"> </div>';
box += '<div class="modal-footer">';
box += '<button type="button" class="btn btn-default" data-dismiss="modal">No</button>';
box += '<button type="button" class="btn btn-primary">Ok</button>';
box += '</div>';
box += '</div>';
box += '</div>';
box += '</div>';
$("body").append(box);
window.confirm = function () {
$(".modal-body").html( arguments[0].replace(/\n/, "<br />") );
$('.modal').modal();
$(".btn-default").on('click', function() {
$(this).modal('hide');
});
$(".btn-primary").on('click', function() {
return true; // this is where I need the caller's HREF,
// to make it actually proceed.
// Return true, obviously, does nothing.
});
};
};
$(document).ready(function() {
$.altConfirm();
});
Any hint? Please note that I would like this to be a drop-in replacement for standard javascript confirm, so modifying the way the confirm itself is called it is not a possibility (if this plugin is active -> then the modal is shown, if this plugin is not active -> then the standard confirm is fired).