mardi 3 février 2015

TypeError: context is undefined in javascript


I have the following code:



function pop_open () {

var contents = $( this ).html() ;

if (contents.match("^http")) {
console.log('contents',contents);
$that = $( this );
$url = contents;

$.ajax({
type:"POST",
url: "Ajax/getHtml",
context: $that,
data: { u : 'http://ift.tt/gbk8l4' },
dataType: 'html',
error: function(jqXHR, textStatus, errorThrown) {
console.log('error');
console.log(jqXHR, textStatus, errorThrown);
}
}).done(function(html) {

$link = $('<a href="myreference.html" class="p1" data-html="true" data-bind="popover">');
$link.data('content', html);

$that = $(this);

// Trigger the popover to open

$link = $(this).find('a');
$link.popover("show");
});

}

}

$('td').hover( pop_open(), function() {
$link = $that.find('a');
$link.popover("hide");
$that.html($url);
});


I am getting the error in the title. What am I doing wrong?





Aucun commentaire:

Enregistrer un commentaire