DropDownList with dirtyforms jQuery plugin - forms

I'd like to use the jQuery plugin dirtyForms to check if my forms are dirty or not.
But it looks like the DropDownList is not based on the standard select HTML tag.
It seems instead that it's using HTML tag.
Why this choice ? Because of that the jquery plugin dirtyForms don't set my forms dirty when I just change a DropDownList value...

I know nothing about kendo-ui or dirtyForms so I will do my best to answer this by looking at the API. The kendo-ui DropDownList has a change event that looks to only get fired whenever the input in a DropDownList is changed. Additionally dirtyForms has a way of you manually setting the form to dirty. Putting the two together I would guess the following should work.
$("#dropdownlist").kendoDropDownList({
change: function(e) {
$('form').dirtyForms('setDirty');
}
});
Edit: Since you seem to want this to effect all DropDownList's, you might be able to do the following.
kendo.ui.DropDownList.fn._change = function(e) {
if(this.element && this.element.form)
$(this.element.form).dirtyForms('setDirty');
}
This seems kind of hackish and I am not sure if I would recommend doing it though. It might break other things.

This sounds like this is a bug that was fixed in pull request 27, which allowed for cross-browser compatibility with select elements.
Or, it could be that you have not properly ignored all of the 3rd party widgets on the page that have anchor elements in their markup.

Related

Joomla 'PageNavigation' Plugin

If this isn't possible please let me know!
I'm hoping there's a solution to what I'm asking.
I need to move the Next/Prev buttons, located in the pagenavigation plugin to after the <jdoc:include type="component" />; Basically render it anywhere in my templates' index.php?
Is there any way to do this?
This is the code that renders the pagination:
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
?>
<?php endif; ?>
As you can see the pagination is part of the item. As you can see if you look at the pagenavigation content plugin the pagination values are created in response to the onContentBeforeDisplay event. The plugin is hard coded to only work for articles in the single article view.
So to use it in a different component you would really need to create a second plugin for that component (or you could do any component or anything besides the single article view, that all would be easy to code using context).
To locate it in a different place in the single article view you would have to move the block of code to the desired location in the layout. Potentially you could also use css to locate the rendering of the block somewhere else on the page. (But more on this at the bottom.)
Unfortunately (but nor surprisingly given its name) onContentBeforeDisplay comes really late, in the view (unlike with pagination in the backend).
I always find it confusing because this frontend "pagination" property controlled by this plugin has nothing to do with backend pagination which is controlled by a JPagination object. I believe if is because of backward compatibility all the way to 1.0. ALso because the template chrome for pagination chrome are called pagination.php.
That leads me to the next thing I'll mention. You can make a file pagination.php and put it in the html folder of your template. You can see an example of this in the core template protostar. THat's where you would do the CSS or whatever other tricks you want to do to make the pagination do what you want. I think if you work hard enough at it (possibly using javascript or possibly calling that file from a module) you can pretty much achieve whatever you want.

Enabling button on any value change in JSF form

I have multiple fields including text,checkbok box, drop-down etc in jsf form, which is showing values from DB.I would like the submit button to be disabled by default and to only be clickable if the user made changes to any of the fields in the form. Please help !!
For a simple form you can use this jQuery plugin that a user mentioned here.
Edit:
The plugin is quite simple to use, and powerful, because for example you will have your buttons disabled again if you revert changes inside an input field.
Just make sure that you include the js file:
<h:outputScript name="path/jquery.are-you-sure.js"/>
And for using it, you have to add the line:
$('#idofyourform').areYouSure();
After that, for enabling and disabling submit buttons you have to add:
//All disabled by default
$('#idofyourform').find('button[type="submit"]').attr('disabled', 'disabled');
//Enabled all when there are changes
$('#idofyourform').bind('dirty.areYouSure', function () {
$(this).find('button[type="submit"]').removeAttr('disabled');
});
//Disable all when there aren't changes
$('#idofyourform').bind('clean.areYouSure', function () {
$(this).find('button[type="submit"]').attr('disabled', 'disabled');
});
Both codes inside your document ready function.
Note that I used button[type="submit"], which is what p:commandButton renders by default. You can use input if it's your case.
NOTE: This plugin also adds an extra functionality the OP didn't ask for (the dialog check when you navigate without saving changes). You can disable this if you want by doing:
$('#idofyourform').areYouSure( {'silent':true} );
Not tested, but I would simply use something like this :
$(document).ready(function() {
$('#formId input[type="submit"]').attr('disabled','disabled');
$('#formId').change(function(){ $('#formId input[type="submit"]').removeAttr('disabled'); });
});
If you don't use any jQuery functions already in the view (any PrimeFaces ajax buttons for example), you might need to add :
<h:outputScript library="primefaces" name="jquery/jquery.js" />

Setting values to a form which is not rendered yet

I have a form within a tab. It is second tab so it doesn't render until you open it.
I have tried to submit data to the form with Ext.getCmp('DetailsForm').getForm().setValues(selections[0]); but it says that it is not a function. Probably because it is not rendered yet. What I have to do?
Set the deferredRender config property of your Ext.tab.Panel to deferredRender: false
That will force the rendering of all tabs instead of just active ones. Now the form will be there. As mentioned before I recommend you also to use myTabPanelRef.down('from').getForm().setValues(selections[0]); to access the form.
subscribe to the second tabs show event OR painted event
then look for the form preferably by using .down() method as this wont look with in the entire DOM.
set the values
Use render event of form panel.
Your code will be something like this -
Ext.getCmp('DetailsForm').on('render', function(){
this.getForm().load(selections[0]);
});

Add Tooltips to helper html.dropdownlist in asp.net mvc

I have a dropdownlist that displays just products codes 101,102,103
If the user hovers over a product code I would like the title to appear as a tooltip.
So it's not your normal DataValue & DataText scenerio, because "101" would be both the display text & the value.
I believe I will need to use jQuery to achive this effect.
And I also believe I would need to set the Title attribute of each list item as the Product Title.
My question is, using helper html.dropdownlist how can I set the title attribute?
Thanks, this is my first day using MVC
We used tipsy once for something very similar. http://plugins.jquery.com/project/tipsy
We actually took it a step further and "created" an attribute like this
<span class="tipsyItem" tipsy="This is my tooltip text!">This is my regular text!</span>
The reason was that tipsy would still show the regular tooltip on occasion. We used some of the advanced settings like this.
$('.tipsyItem').tipsy({title: 'tipsy'});
Plus you can theme it. Also were even able to get it to support html embedded in the tooltips for links and such.
$('.tipsyItem').tipsy({html: true });
Twitter used to use tipsy. I'm not sure if they still do.

How do you programatically remove (not disable) a button from TinyMCE?

I can disable the table button using this:
tinyMCE.activeEditor.controlManager.get('divId_table').setDisabled(true)
but what I'm interested in is actually hiding it. Any idea on how to accomplish that?
Thank you!
First, you have to use the advanced theme.
Then, add this option in the TinyMCE init code.
tinyMCE.init({
...
theme_advanced_disable : "bold, justifyleft, justifyright"
});
I hope this might help someone.
source
list of elements' name here
I'm not familiar with TinyMCE myself, but since you appear to have javascript access to the element itself, all you need to do is set it's display property to "none".
document.getElementById("theButton").style.display = "none";
incase ur trying to hide a specific button, use the following code.
$('.mce_cut').hide() //hides cut button
lookup other button titles using firebug in case u wish to hide something specific.
Incase you are looking to hide specific editor's button, modifiy the jquery selector to select correct sibling/descendent.
alternately, try this ..
tinyMCE.activeEditor.controlManager.controls.ctl00_SPWebPartManager1_g_5005db96_e035_4197_a958_75f008b35061_ctl00_tbKeywords_cut.remove()
Note that ctl00_SPWebPartManager1_g_5005db96_e035_4197_a958_75f008b35061_ctl00_tbKeywords is my asp.net control's id. Don't bother about this if ur not using Asp.net serverside textbox control. In case you are.. <% theTextBoxID.ClientID %> gets u that.
Use the following (using jQuery; a non-jQuery approch is easily built):
var elem = $(ed.id+'_'+'divId_table')
elem.addClass('mceButtonDisabled');
elem.removeClass('mceButtonEnabled');