Joomla custom toolbar button message - joomla

The standard admin toolbar buttons have the possibility that you can give them a message. For example: a "really delete" message or something...
JToolBarHelper::deleteList('Do you wanna really delete?', 'controller.delete');
Is that also possible for a custom button? In the documentation is no parameter for this. http://docs.joomla.org/JToolBarHelper/custom
Did Joomla have another solution? Show the user a message and after his confirmation... execute my code! Is that possible?
Sorry for my bad english :)
thanks!

Sure it is possible :)
Simply add to your component template view (for example:)
administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
this code:
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm(Joomla.JText._('Do you really want to delete these items?'))) {
Joomla.submitform(task);
} else {
return false;
}
}
}
</script>
Just change the task and edit the message and you should be ready to go

Add this code to this url :
administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm('Do you really want to delete these items?')== true)
{
Joomla.submitform(task);
}
else {
return false;
}
}
else
{
Joomla.submitform(task);
}
}
</script>

Related

Changing dropdown selected item in jquery not changing text?

I have a dropdownlist and I am trying to change the selected item but the text is not changing. I am assuming it's because I am doing it client side but I once I've changed the selected item I am un sure how to change the text in the dropdownlist.
JQuery Code: -
function setPhotoStage(photoStageId) {
$("[id*=drpPhotoStages] option").each(function () {
if ($(this).val() == photoStageId) {
$(this).attr('selected', 'selected');
alert($(this).val());
} else {
$(this).removeAttr('selected');
}
});
}
The code above is selecting the correct item in the list if I click on it but not changing it on the form: -
Here is the code when I inspect the dropdown. Some how I need to change the filter-option-inner-inner to the newly selected text: -
Any help please, I've looked everywhere and cannot find a solution.
I managed to sort it by adding refresh to the dropdown: -
function setPhotoStage(photoStageId) {
$("[id*=drpPhotoStages] option").each(function () {
if ($(this).val() == photoStageId) {
$(this).attr('selected', 'selected');
} else {
$(this).removeAttr('selected');
}
});
$("#drpPhotoStages").selectpicker('refresh');
}

Closing the browser event

I'm currently developing a firefox extension and I need to know when the user closed the browser , so I can call a function. I've searched firefox addon sdk documentation and I haven't found anything. Is there a solution to my problem?
require("sdk/system/unload").when(function(reason) {
if (reason === 'shutdown') {
handleShutdown();
}
if (reason === 'disable') {
handleShutdown();
}
});
tried this?
<script type="text/javascript">
$(document).ready(function(){
window.onbeforeunload = function() {
var msg =" If you're not interested please let us know what we can do to improve."
return msg;
} });
</script>

Clear Session Storage when Clicking Outside

I'm using Meteor and have the code below that stores _id into session:
'click .players': function(){
var playerId = this._id;
Session.set('selectedPlayer', playerId);
The session above is set when user clicks within <li class="players">
I would like to clear the session data when user clicks outside of <li class="players">
What will be the best way to do this?
Thanks !
This solution is a little limited, because the selector :not("li.players") is within the template, which means that you may click somewhere outside the template and it will not fire a click event. It is advisable to put the click event under body template but it will still not fire a click event when you click the html part.
if (Meteor.isClient) {
Template.body.events {
'click :not("li.players")': function(e) {
Session.set('selectedPlayer', null);
}
}
}
For more precisely, this might help you out.
if (Meteor.isClient) {
$(document).click(function(e) {
e.stopPropagation();
var target = $(e.target);
var players = $('li.players');
if (!players.is(target) && players.has(target).length === 0) {
Session.set('selectedPlayer', null);
}
})
}
You can do:
'click :not(".players")': function(ev){
Session.set('selectedPlayer',null);
}
:not() css selector docs

joomla 3 custom component checkout record

Iam in the edit view of one of my component views.
When I go back to the list view, with the cancel button of joomlas toolbar, the list view appears, but the record is locked. It seems that the record is not checked out correct.
In this case, there is no special function in the appropriate controler for canceling. Only for saving and some other tasks.
Iam not able to unlocking the records due to my view in the backend.
In the view there is a typical javascript for using the submit button:
<script type="text/javascript">
js = jQuery.noConflict();
js(document).ready(function() {
});
Joomla.submitbutton = function(task)
{
if (task == 'master.cancel') {
Joomla.submitform(task, document.getElementById('master-form'));
}
else {
if (task != 'master.cancel' && document.formvalidator.isValid(document.id('master-form'))) {
Joomla.submitform(task, document.getElementById('master-form'));
}
else {
alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>');
}
}
}
</script>
Where should I go into, to activate the checkout function when leaving back to the listview from the edit view?
Same problem in case of saving records.
thx Perino
I found the problem. The view is build up of different models and I deactivated
$this->item = $this->get('Item');
in view.html.php. Activating, will result in correct checkin/out of the record.

Click on link to hide all other content divs

Example: (werkwijze is custom, i also have the same code with other names like -contact)
$(function() {
$('#activator-werkwijze').click(function(){
$('#overlay-werkwijze').fadeIn('fast',function(){
$('#box-werkwijze').animate({'bottom':'0px'},800);
});
});
$('#boxclose-werkwijze').click(function(){
$('#box-werkwijze').animate({'bottom':'-600px'},800,function(){
$('#overlay-werkwijze').fadeOut('fast');
});
});
});
activator shows the content, boxclose closes the content.
clicking all activators opens all content while it needs to open only one and close the others..
edit got it fixed:
This is the script which works, (the overlay is useless) jsfiddle.net/8y7Sr/126/
You need to provide more information about how you are calling the pop-up script. If you are using jquery, you can just close all and then open one
$('.className').slideDown(200);
$('#specificItem').slideUp(200);
But again, you should explain how you are doing the calls in more detail for a better answer
example, put inside function jQuery
if($('.hide').css('display')=='block'){ $('.hide').slideUp(); }else{ $('.hide').slideDown(); }
$(function() {
$('.activator').each(function(){
$(this).click(function(){
showHideAnimation(clickedObj);
});
});
}
function showHideAnimation(clickedObj)
{
$('.activator').each(function(){
if($(this).id == clickedObj.id) {
$(this).fadeIn('fast',function(){
$(this).animate({'bottom':'0px'},800);
});
} else {
$(this).animate({'bottom':'-600px'},800,function(){
$(this).fadeOut('fast');
});
}
}
}
Please try this if it doesn't work properly then replace $(this) with only this

Resources