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
Post a Comment