the function passed to ready). Functions are executed in the scope
they are called, so you write them like they were already inside the
click handler.
$(document).ready(function() {
function yourAjaxFunction(){
...
// 'this' in here will be the current element in each()
};
$("#paradigm_all").click(function(){
$("input[name^='paradigm']").each(function(){
if(this.checked){
yourAjaxFunction();
yourCSSFunction();
//here 'this' == this inside the called functions
}
});
});
});
hope that helps.
- ricardo
On Feb 25, 5:00 am, heohni <heidi.anselstet...@consultingteam.de>
wrote:
> Hi,
>
> I have some jquery code within the
>
> $(document).ready(function() {
> $("input:checkbox").click(function(){
> .... check if checked or unchecked....
>
> ... do some ajax stuff .....
>
> .... do some css class exchange stuff ......
> });});
>
> (This is the function to manipulate my code on a single checkbox
> event)
>
> The ajax part and the css class stuff I want now to "surround" as
> function in order to use it in another function:
>
> $(document).ready(function() {
> $("#paradigm_all").click(function(){
> var checked_status = this.checked;
> $("input[name^='paradigm']").each(function(){
> this.checked = checked_status;
> if(checked status == true){
> _call_my_ajax_function();
> _call_my_css_class_function
> }
> });
> });});
>
> (This is the function to manipulate my code when the checkbox "check
> all / uncheck all" was checked or unchecked)
>
> To be honest I am a little bit lost in the syntax and not sure how to
> structure it well in order to be able re-using the functions.
> Would be great if someone could give me a hand with it!
> Thanks!
No comments:
Post a Comment