This is part of a code. The question is, does this line "$("#b_facetNewChild").button().click(function(){" means that the following should be fired when the button “facetNewChild” is clicked? Because there is no “onClick” function at the button. Also, can you explain briefly, what does it mean to have this nested into another function “newChildFacet()” and how to call it?
Sorry, but I am new to javascript.Thanks!
function newChildFacet()
{
// button click
$("#b_facetNewChild").button().click(function(){
//get selected fId
var $fId=getSfSelectedFIds();
if($fId.length>0 && $fId.split(",").length!=1)
{
messageBox("Tip","Please select <b>ONE</b> as the parent facet. If no facet is selected, the new facet will be created under <b>root</b>.");
return false;
}
//some more stuff here!
});
// newChildFacetDialog
$("#newChildFacetDialog").dialog({
autoOpen: false,
modal: true,
title: "New Child Facet",
buttons: {
"Cancel": function() {
$(this).dialog('close');
},
"Create": function() {
//get data
var $parentId=getSfSelectedFIds();
});
$(this).dialog('close');
}
}
});
}
First, yes it bound as a
clickevent handler, so it’ll run when#b_facetNewChildis clicked – you won’t see this in source, it’s stored elsewhere in the DOM.You can call it by invoking the
clickevent handlers on that element, like this:It doesn’t matter that it’s a nested/anonymous function, all we care about here is it’s a
clickevent handler on that element, so you can trigger it any of the following ways: