If I had something like:
App = {
editingMode: function ()
{
function setEditingMode(entityID) {
$('#editingMode').val('1');
$.ajax({
type: "POST",
url: "/Organisations/Manage/LockEntity/",
data: "entityID=" + entityID
});
}
function setEditingModeOff(entityID) {
if ($("#myform").valid() == true)
{
$('#editingMode').val('0');
$.ajax({
type: "POST",
url: "/Organisations/Manage/UnlockEntity/",
data: "entityID=" + entityID
});
}
}
}
};
How would I run one of the inner functions?
App.editingMode();
but then what would I do to get at the setEditingMode
??
You can use a different structure to accomplish what you want. I don't know if it would break something else you are using, so I'll just give you an example. I'm not sure this is the actual solution, please take a look and tell me if that's not what you need. If you use:
var App = {
editingMode:
{
setEditingMode: function(entityID) {
$('#editingMode').val('1');
$.ajax({
type: "POST",
url: "/Organisations/Manage/LockEntity/",
data: "entityID=" + entityID
});
},
setEditingModeOff: function(entityID) {
if ($("#myform").valid() == true)
{
$('#editingMode').val('0');
$.ajax({
type: "POST",
url: "/Organisations/Manage/UnlockEntity/",
data: "entityID=" + entityID
});
}
}
}
};
you can call editingMode's methods like this:
App.editingMode.setEditingModeOff(1);
Notice that they will still be encapsulated within App, you don't necessarily move them to the global scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With