28 Ekim 2009 Çarşamba
Attach External JavaScript File
I'm sure you have common functions that you are using in many entity's javascript part(onLoad,onChange,onSave). Actually the best inheritance is not copy-paste so you can keep all those functions in one *.js file and while form is loading you can attach to form with the following way.
var script = document.createElement('script');
script.language = 'javascript';
script.src = '/CustomScripts/MyCustomJavascriptFile.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.onreadystatechange = function()
{
if (this.readyState == 'complete' || this.readyState == 'loaded')
{
//You can call your functions here.
}
}
We will be adding some useful functions to this javascript file on next posts.
Televizyonunu yeni açan seyircilerimiz için:
Yapmayın. Öyle bir fonksiyonu lazım olan her entity için sürekli kopyala yapıştır yapmayın, ayıp. Insan gibi bir base javascript dosyanız olsun; gerekli, en az 2 defa kullanılmış fonksiyonları bu dosyada toplayın sonra hangi entity'den istiyorsanız onun pageLoad fonksiyonuna aşagıdaki blog'u yazın, bitsin.
var script = document.createElement('script');
script.language = 'javascript';
script.src = '/CustomScripts/MyCustomJavascriptFile.js';
document.getElementsByTagName('head')[0].appendChild(script);
script.onreadystatechange = function()
{
if (this.readyState == 'complete' || this.readyState == 'loaded')
{
//şimdi burdan paşa paşa çagır fonksiyonunu.
}
}
Sonraki postlarda "işe yarar, ooo helal, yok artık" şeklindeki fonksiyonları ekleyecegiz.
Kaydol:
Kayıtlar (Atom)