I want to change the way URL path is forming. For example user creates new content. When user enters some text to the Title field I want to process this text and set some string to URL path. Next I want to update text in Alias vertical-tab.
1. I included reference to myTest.js to .info file
scripts[] = js/myTest.js
2. myTest.js contains code:
(function ($) {
Drupal.behaviors.myBehavior = {
attach: function (context) {
$('#edit-title', context).keyup(function () {
var str = $(this).val();
var urlStr = myFuncThatReturnsURL(str);
var editPathAlias = $('#edit-path-alias', context);
editPathAlias.val(urlStr);
return true;
});
}
}
})(jQuery);
function myFuncThatReturnsURL(sourceStr) {
...
}
So, because I'm newbie in javascript, jQuery and Drupal, I have next questions:
1. Is this right to update URL input field (#edit-path-alias) in such manner?
2. How to update text in Alias vertical-tab automatically? If I write something like this
$('#edit-path-alias', context).change(function () {
//change text in Alias vertical tab
......
}
it will work only if focus set/leave '#edit-path-alias' input field.