I would like to be able to identify and process link meta data with live events. So if I have a link like so:
<a href="#workorder_new" data-city="austin" data-state="tx">Click here</a>
Somehow I need to get the above element (specifically data attributes) into the "live" function and then call on a Javascript function, with jQuery-mobile live elements, something like:
$('[href=#workorder_new]').live('click', function()
{
var target = $(this);
var workorder_new = new workorder_new_controller(target.data);
$('#workorder_new').bind('pagebeforechange',function(event, ui)
{
workorder_new.before();
});
$('#workorder_new').bind('pageshow',function(event, ui)
{
// var page = event.target.id;
workorder_new.after();
});
});
function workorder_new_controller(data)
{
var city = data.city;
var state = data.state;
this.before = function(){
// console.log(data);
}
this.after = function(){
// console.log(data);
var today = new Date();
var tomorrow = new Date(today.getTime() + (24 * 60 * 60 * 1000));
$('#workorder_new_form [name=due_date]').val(readable_date(tomorrow));
}
}
So this is just some code I'm playing around with right now trying to piece it together. But I think I'm way off course here. Could somebody lend some advice for how I could get this working as expected? Or at least some tips to get me on the right path? Thanks!