Leave pop-up box on save
Leave pop-up box on save
I would like the pop up box to hide after I save a child record. Can someone please help me?
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
Can you give a bit more detail? I don't see a popup when I save, only the message bar below the navbar header - and that disappears automatically after a few seconds.
Re: Leave pop-up box on save
I think he talks about the modal thath opens when you add a child record from a master form, for example, a new category from a product form. Save&Close
/Giuseppe
Professional Outsourcing Services
Professional Outsourcing Services
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
I don't use that mode (yet) but I can investigate. It is probably just a matter of a little jquery in a hook.
I'm working on a new project that will use the embedded mode for children, so it might be useful to poke around anyway.
I'm working on a new project that will use the embedded mode for children, so it might be useful to poke around anyway.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
grep the AG code for 'embedded'
Re: Leave pop-up box on save
I'm looking into the code, and I'm not totally sure what embedded mode is, or how to enable, sorry.grimblefritz wrote:grep the AG code for 'embedded'
/Giuseppe
Professional Outsourcing Services
Professional Outsourcing Services
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
It's a var set in the AG code when you're not opening details in a new window.
Re: Leave pop-up box on save
Yes I am talking about the modal that pops up when creating a child record. I just want to know how to close it automatically when you save a new entry. This is an awesome community and I'm sure someone will figure it out.
Re: Leave pop-up box on save
Add the below code to the hooks/tablename-dv.js (where tablename is the name of the child table). This should do the job.
Code: Select all
$j(function(){
if(($j('input[name=Embedded]').val()==1)){
$j('form').submit(function(){
window.parent.jQuery('.modal').modal('hide');
}
})
})
Re: Leave pop-up box on save
It says there is a missing syntax
SyntaxError: missing ) after argument list
})
I tried to fix it but it's not working.
SyntaxError: missing ) after argument list
})
I tried to fix it but it's not working.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
Try this:
Code: Select all
$j(function(){
if($j('input[name=Embedded]').val()==1){
$j('form').submit(function(){
window.parent.jQuery('.modal').modal('hide');
}
});
});
Re: Leave pop-up box on save
you were all on the right track!! This did the trick,
Thanks for the help! This community is awesome!
Code: Select all
$j(function(){
if($j('input[name=Embedded]').val()==1){
$j('form').submit(function(){
window.parent.jQuery('.modal').modal('hide');
})
}
})
Re: Leave pop-up box on save
I've used this and it works perfectly. Quick question.
I have a need to run a function on delete. Is there something similar to "$j('form').submit" for delete, as my function currently only works when creating and updating records.
I have a need to run a function on delete. Is there something similar to "$j('form').submit" for delete, as my function currently only works when creating and updating records.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
You can use something like:
Code: Select all
$j('#delete-button-id').on('click', function() {
// your function code
});
Re: Leave pop-up box on save
Thanks for the response. Sorry, I should have been clearer.
I need the function to run after the child has been deleted in the modal window of the parent, as the function calls an ajax file to recalculate a subtotal value of a field in the parent. I think with the above code it will run while the record is being deleted which may lead to inconsistent results, unless something like setTimeout is used.
The function itself is in the tablename-dv.js of the parent. I'm having slight issues with it at the moment but got it to work on submit, just not on delete. I posted on stackoverflow with regard to another related issue. You can see the relevant code there. http://stackoverflow.com/questions/3944 ... ting-child
Thanks for all your help.
I need the function to run after the child has been deleted in the modal window of the parent, as the function calls an ajax file to recalculate a subtotal value of a field in the parent. I think with the above code it will run while the record is being deleted which may lead to inconsistent results, unless something like setTimeout is used.
The function itself is in the tablename-dv.js of the parent. I'm having slight issues with it at the moment but got it to work on submit, just not on delete. I posted on stackoverflow with regard to another related issue. You can see the relevant code there. http://stackoverflow.com/questions/3944 ... ting-child
Thanks for all your help.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
Ah, I see your point. I don't use the parent-child window mode, so I don't have any suggestions.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
I only had a moment to look at the AG code, but it looks to me like the tablename_after_delete() hook function is called even when the child is modal.
Re: Leave pop-up box on save
I tried including it there, that did not work (keep in mind that I could have been doing something wrong as I'm new to this).
I ended up creating another function in the parent-dv.js, in that function I set a small delay so the child record actually gets written to the DB before calling the function that would calculate the subtotal sum of all children. See the two functions below:
And in the child-dv.js I just used this:
That seems to work for creating, updating and deleting records. Unfortunately setting the delay in the child itself did not seem to work consistently and did not work when deleting records.
One can argue that I could just set the delay in the main function of the parent, but I also call it on page load so don't really want to mess with it.
It is not pretty, but it works.
I have tried a number of different ways, even tried to trigger the function on modal close as documented in bootstrap docs, with something like, which proved problematic as the modal ID's are randomly generated and for the life of me I could not tie it to the class itself.
Thanks for trying to help. Even though my solution is not pretty, if you look closely, some of the code above is yours from around the forum. Thank you for your contributions, without them I wouldn't have even gotten this far.
I ended up creating another function in the parent-dv.js, in that function I set a small delay so the child record actually gets written to the DB before calling the function that would calculate the subtotal sum of all children. See the two functions below:
Code: Select all
function update_lineitems_subtotal_delay(){
setTimeout(update_lineitems_subtotal, 100);
//alert('Delay Triggerred'); //for testing
};
function update_lineitems_subtotal(){
var qid = $j('[name=SelectedID]').val();
if(!isNaN(qid)){
$j.ajax({
url: 'hooks/ajax_quote_subtotal.php',
data: { qid: qid },
success: function(data){
$j('#LineItemsSubtotal').val(data);
$j('#Shipping').keyup();
//alert('Update Triggerred'); //for testing
}
});
}else{
$j('#LineItemsSubtotal').val('0');
$j('#Shipping').keyup();
//alert('submitted!'); //for testing
}
};
Code: Select all
if($j('input[name=Embedded]').val()==1){
$j('form').submit(function(){
parent.update_lineitems_subtotal_delay();
window.parent.jQuery('.modal').modal('hide');
});
};
One can argue that I could just set the delay in the main function of the parent, but I also call it on page load so don't really want to mess with it.
It is not pretty, but it works.
I have tried a number of different ways, even tried to trigger the function on modal close as documented in bootstrap docs, with something like
Code: Select all
$j('#myModal').on('hidden.bs.modal', function () {// do something…})
Thanks for trying to help. Even though my solution is not pretty, if you look closely, some of the code above is yours from around the forum. Thank you for your contributions, without them I wouldn't have even gotten this far.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Leave pop-up box on save
You're welcome, but I can't take credit for the code. Like most people, sometimes I code from scratch, and sometimes I see how others have done things and adapt for my needs. Posting the end result here, however? That is purely to give back.