Is wplink error “Cannot read property ‘selectionStart'” solved?

I am trying to integrate the wplink function into my custom post type using custom fields.

Unfortunately, I am facing following problem:

Uncaught TypeError: Cannot read property ‘selectionStart’ of undefined
at Object.refresh (wplink.js:165)
at Object.open (wplink.js:138)
at HTMLInputElement.<anonymous> (media-gallery.js?ver=1.0.0:106)
at HTMLInputElement.dispatch (jquery.js?ver=1.12.4:3)
at HTMLInputElement.r.handle (jquery.js?ver=1.12.4:3)

Based on other reports i understand, that “Cannot read property ‘selectionStart’ of undefined” occurs after wordpress 4.9.5.

Does anyone know, if a proper solution has been made for this error?

For you knowledge – my jQuery code is this:

jQuery(document).ready(function ($)
{

$(‘.link-target’).click(function (e)
{
wpActiveEditor = true;
wpLink.open();
return false;
});

$(‘#wp-link-submit’).on(‘click’, function(event)
{
var linkAtts = wpLink.getAttrs();//the links attributes (href, target) are stored in an object, which can be access via wpLink.getAttrs()
$(‘your_url_textfield’).val(linkAtts.href);
wpLink.textarea = $(‘body’);
wpLink.close();
event.preventDefault ? event.preventDefault() : event.returnValue = false;
event.stopPropagation();
return false;
});

$(‘#wp-link-cancel’).on(‘click’, function(event)
{
wpLink.textarea = $(‘body’);
wpLink.close();
event.preventDefault ? event.preventDefault() : event.returnValue = false;
event.stopPropagation();
return false;
});

});

Read more here:: Is wplink error “Cannot read property ‘selectionStart'” solved?

Leave a Reply

Your email address will not be published. Required fields are marked *