s = s.replace(/[^\x00-\x7F]/g, "")
add a JS function
input
event is HTML5, feels like onchange without the need to lose focus on the element. It's not supported by IE8 and below, which should use onpropertychange
. onkeydown oncut onpaste
require('./parameterize.js')
$(document).on("turbolinks:load", function() {
$('form').on('input', '.parameterize-to', function(event) {
console.log("parameterize value updated")
let tid = $(this).attr('dst-id');
console.log("DEBUG:: The dst ID is: %s!",tid)
let content= $(this).val().trim()
console.log("DEBUG:: The form value is: %s!",content)
let slug = parameterize(content)
console.log("DEBUG:: Set value of %s to is: %s!",tid,content)
$("#"+tid).val(slug);
});
});
Apply it in views. Set class and ID properly. It works with input, cut & paste in Chrome