Is there no way to reduce javascript function coding, where the function / call process is the same? I'm not entirely a good way to make sure this, but it's the code below ...
Javascript:
$ (function () { $ ('# (Art Open: False, Title: "Shopping Cart", Width: 600, Minwheat: 600, MaxWidth: 600, Minhite: 300, MaxHyight: 600, Model: True, Show: {Effect: "Blind"} , Hide: {effect: "fade"}} $ ('#' cartilink). ('Click', function () {$ ('# cartadyology') .dialog ('open');})}} ; $ (Function () {$ ('# Login'). Dialiog ({Auto Open: False, She Title: "login / registration", width: 650, maxwidth: 650, height: 250, maximum height: 600, resizable: false, model: (effect), "pseudo"}} $ ('# loginink') ('Click', function () {$ ('# login_gog') .dialog ('open');});}); $ (function () {$ ('# logog diallog'). Dialog ( {AutoOpen: false, title: "logout confirmation", width: 250, height: 250, resizable: wrong, model: true, show: {effect: "blind"}, hide: {effect: "fade"}} ; $ ('# Logout dialog'). ('Click', F Quation () {$ ('#logogdialog') .dialog ('open');});}); $ (Function ($ ('(myAccountDialog') .dialog ({autoOpen: false, Title: "Login / Registration", Width: 600, Minimum Wide: 600, MaxWidth: 600, Minimum Hight: 300, Maximum Hight: 600, model: true}); $ ('# MyAccountDialog'). ('Click', function () {$ ('#MyAccountDialog') .dialog ('open');});});
The main document idea:
If I'm trying to tinker with the idea of calling the class, then using the devil id to correct a central javascript function (if possible) It is easy to understand that it is easy to understand.
The suggestion I give is defining a function that is used by all numbers The window will be used to start:
function show_dialog (selector, settings) {var default_settings = {modal: true, autoOpen: false, minwthth: 600, minhite: 30, ... } $ Advanced (default_settings, settings); $ (Selector) .dialog (default_settings); }
You will pass the object containing all the unique settings for the selector for the relevant Dom Element and for each dialog. Within the function, a default_settings
object is defined - it contains all the calls that are the same on all calls, but the objects set on the function can override the set that "merge" objects Example usage:
show_dialog ("#cartDialog", {minWidth: 700, maxWidth: 500, minHight: 100, maxHeight: 800});
This function call will use #CartDialog
as its selector and the default minWidth
and minHyight
override All other settings defined in show_dialog
will be the same, modal
, autoOpen
, etc ...
Comments
Post a Comment