Files
convore.json/groups/jquery/when-to-use-function-name-javascriptcode-or-function/messages.json
T
2012-02-21 01:15:00 -05:00

1 line
3.9 KiB
JSON

[{"user_id": 15165, "stars": [], "topic_id": 8276, "date_created": 1298455117.3367591, "message": "I would like to know when to use a jQuery function or a JavaScript function", "group_id": 428, "id": 186484}, {"user_id": 13568, "stars": [], "topic_id": 8276, "date_created": 1298456662.9750791, "message": "jQuery is a JavaScript Library designed for simplifying your scripting. So if you want to write less and easier code, especially for HTML document traversing, event handling, animating and Ajax interactions, use jQuery. Although, there are many plugins for jQuery, so you can use lots of functions they already exists, without reinventing the wheel again and again ...", "group_id": 428, "id": 186555}, {"user_id": 15165, "stars": [], "topic_id": 8276, "date_created": 1298471138.729089, "message": "Yes but .... how about dealing with databases? I need functions in order to work with Ajax (under jQuery) to validate fields, etc ... What's the diference?", "group_id": 428, "id": 187722}, {"user_id": 15100, "stars": [], "topic_id": 8276, "date_created": 1298480727.231617, "message": "If you had a function to attach, then you could do it with jQuery, e.g., $(document).ready(function() { ... });", "group_id": 428, "id": 188771}, {"user_id": 13249, "stars": [], "topic_id": 8276, "date_created": 1298481395.3994651, "message": "jQuery is JavaScript.. make declared functions when you want more re-usability. I don't know of any set in stone rules when an anonymous jQuery function is a better or worse choice than a declared function. If you are only using something once in a callback for example, an anonymous function probably makes more sense, but would work just as well with a declared function..", "group_id": 428, "id": 188849}, {"user_id": 15100, "stars": [], "topic_id": 8276, "date_created": 1298480701.796201, "message": "jQuery functions are typically attached to things -- not standalone like you've described here. Standalone functions should be written in the first way.", "group_id": 428, "id": 188767}, {"user_id": 8327, "stars": [{"date_created": 1298574114.43607, "user_id": 486}], "topic_id": 8276, "date_created": 1298501945.927053, "message": "There's a huge difference between the examples you suggest;\nfunction name() { /* code */ } merely declares a function for calling later\n$(function() { /* code */ }) registers an anonymous callback to be run onDOMReady\nUse the first in normal code, use the second to initialise your page", "group_id": 428, "id": 192635}, {"user_id": 15165, "stars": [], "topic_id": 8276, "date_created": 1298533034.371105, "message": "MAL: Thank you for your answer. Now I understand a litte more how to deal with jQuery!", "group_id": 428, "id": 195895}, {"user_id": 13249, "stars": [], "topic_id": 8276, "date_created": 1298567592.018702, "message": "I assumed that you didn't mean $(function() { } ) literally, but just an anonymous function in general...", "group_id": 428, "id": 199195}, {"user_id": 15165, "stars": [], "topic_id": 8276, "date_created": 1298621232.9330151, "message": "I'm interested in knowing both: anonimous functions and named functions!", "group_id": 428, "id": 206557}, {"user_id": 20229, "stars": [], "topic_id": 8276, "date_created": 1299838866.09393, "message": "proper way to define a jQuery function which you can attach to selector objects:", "group_id": 428, "id": 321094}, {"user_id": 20229, "stars": [], "topic_id": 8276, "date_created": 1299838929.7740281, "message": "$(this) inside the function will point to the selector object you've attached the function.", "group_id": 428, "id": 321102}, {"user_id": 20229, "stars": [], "topic_id": 8276, "date_created": 1299838880.6861019, "message": "$.fn.functionName = function() {...}", "group_id": 428, "id": 321096}, {"user_id": 6604, "stars": [], "topic_id": 8276, "date_created": 1302330933.1614649, "message": "when you wrap an anonymous function in the jQuery object, you're using shorthand for $(document).ready(function(){}); no more, no less", "group_id": 428, "id": 600162}]