jQuery("body").on("change", "#fontSelector", "change", function () {
var selectedFont = jQuery("#fontSelector").val();
layoutDesigner.selectFont(selectedFont);
});
I wanted to replace the above code with the following:
jQuery("#fontSelector").off("change");
jQuery("#fontSelector").on("change", function () {
var selectedFont = jQuery("#fontSelector").val();
layoutDesigner.selectFont(selectedFont);
});
Sure, I could rewrite this manually. But this takes a long time with dozens of such event handling constructs, all with different selectors, events and functions. Structural search and replace to the rescue.
But instead of writing how you could do this with structural search and replace, I recorded a little screencast which demonstrates the concept. The video can be found here: https://www.youtube.com/watch?v=Jb-YNgDClKg
No comments:
Post a Comment