Moving jQuery code into a function? -



Moving jQuery code into a function? -

i have next code apply when document ready:

$(document).ready(function () { $('#updatedialog').dialog({ autoopen: false, width: 400, resizable: false, modal: true, buttons: { "update": function () { $("#update-message").html(''); //make sure there nil on message before go on $("#updatereferenceform").submit(); }, "cancel": function () { $(this).dialog("close"); } } }); });

is there way can take actions of code , move function. have 1 line phone call function within $(document).ready(function () {

yes it's simple:

function foo() { $('#updatedialog').dialog({ autoopen: false, width: 400, resizable: false, modal: true, buttons: { "update": function () { $("#update-message").html(''); //make sure there nil on message before go on $("#updatereferenceform").submit(); }, "cancel": function () { $(this).dialog("close"); } } }); } // first way: $(function(){ foo(); }); // sec way: $(document).ready(function () { foo() }); // mathias bynens version save conflicts global vars. (function() { var foo = function() { /* */}; $(foo); }() );

jquery

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -