Every time you create a jQuery UI dialog, you find yourself specifying the same few options, among others:
You long for your code to be as succinct as it once was. What happened to the simple beauty of $('#msg').dialog();?
Override the plugin defaults before init by extending $.ui.pluginname.defaults:
If you were only looking to improve the readability a bit, you could simply put the options in a variable and pass them to the plugin init:
But this recipe is about more than just readability and code beauty. It’s about changing the default behavior of a plugin you didn’t write. Plus, it makes it so you can get back to the simple no-options init:
As Dave Methvin famously said, “It could n’t get any shorter unless it read your mind.”
Of course, you still have the option of overriding even these custom defaults by passing custom options to the plugin init, as in the previous recipe.
Don’t forget that plugin options are cloned and extended from the defaults at the time of in it. So, extending $.ui.dialog.defaults after a <div>has already been initialized as a dialog will have no effect on that dialog, even if that in it was done with no custom options. The effect will be on any dialogs initialized after the defaults were overridden.
J Query Related Interview Questions
|HTML 4 Interview Questions||HTML Interview Questions|
|HTML 5 Interview Questions||Zend Interview Questions|
|JqueryUI Interview Questions||Dynamic HTML Interview Questions|
|XQuery Interview Questions||jQuery Mobile Interview Questions|
J Query Related Practice Tests
|HTML 4 Practice Tests||HTML Practice Tests|
|HTML 5 Practice Tests||Zend Practice Tests|
|PHP and Jquery Practice Tests||J Query Practice Tests|
|CodeIgniter Practice Tests||Dynamic HTML Practice Tests|
J Query Tutorial
Selecting Elements With Jquery
Beyond The Basics
Faster, Simpler, More Fun
Html Form Enhancements From Scratch
Html Form Enhancements With Plugins
Interface Components From Scratch
User Interfaces With Jquery Ui
Jquery Ui Theming
Jquery, Ajax, Data Formats: Html, Xml, Json, Jsonp
Using Jquery In Large Projects
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.