How to enable a checkbox using AUI script - yui

This is the code to get the value of a checkbox
var email = A.one("#<portlet:namespace/>email").attr('checked');
What is the code to set/enable the checkbox with a tick ?
A.one("#<portlet:namespace/>email").prop('checked', email); //this does not work
A.one("#<portlet:namespace/>email").set('value', email);//this also does not work
Many thanks

You can use Node#set:
A.one("#<portlet:namespace/>email").set('checked', true);
Or you can use Node#setAttribute:
A.one("#<portlet:namespace/>email").setAttribute('checked', true);

Related

CRM form. Preset Field is not saved on after Clicking Save button

I am working on CRM 2011.
On Form_onLoad event I am presetting the value of a field.
mdg.PreSetField("address1_line1","Amsterdam");
but after clicking on save button my field address1_line1 is blank.
To check I put a alert on Form_onsave function.
alert("address =" + (Xrm.Page.getAttribute("address1_line1").getValue()));
In alert,I get the value of address1_line1 field but finally address1_line1 is blank.
mdg.PresetField function is as follows
mdg.PreSetField = function(attributeName, value) {
var attribute;
if (attributeName.setSubmitMode) {
attribute = attributeName;
}
else {
attribute = Xrm.Page.getAttribute(attributeName);
}
attribute.setSubmitMode('never');
attribute.setValue(value);
attribute.addOnChange(function() {
attribute.setSubmitMode('always');
});
};
I solved it..
in my custom mdg.PresetField function earlier code was
attribute.setSubmitMode('never');
I changed never to always and now it is working..
mdg.PreSetField("address1_line1","Amsterdam");
This code is not part of the CRM JavaScript API so I assume it's a custom library? Have you added this script to the list of webresources available on the form? Also make sure it comes before the script you are trying to use it in.

How to empty textbox befor ModalPopupExtender show?

My code is to insert the text from textbox, I did my code well but I want to empty the textbox before ModalPopupExtender show. I did my code but It didn't work.
protected void Btn_monthlyemployee_Click(object sender, ImageClickEventArgs e)
{
var Comment = (TextBox)((ImageButton)sender).Parent.FindControl("txt_monthlyemployee");
ftier.Addcomment(LblMonthlyPID.Text, LoggedUserID, txt_monthlyemployee.Text, DateTime.Now, DateTime.Now, false);
Comment.Text = string.Empty;
ModelExtenderPost.Show();
}
You don't have provided enough information although i am giving you some good techniques to resolve this
Your code should be work i don't know why its not working
You can have a jquery method
when your button clicked
$('#idofmonthlyeployeed').click(function()
{
$('#commentboxid').val('');
return false;
});
You can see working example here Fiddle
Or you can have a update panel issue if you don't have triggered button of your idofmonthlyeployeed
So please add trigger of idofmonthlyeployeed
I hope this will help you regards.....:)

click to replace value, shift + click to append value using jquery

I have a list with items.
When I click any of these items, I copy its id-value into a form text-field.
Everytime I click, it replaces the value, which is correct by default. But what I would like to add, is a way for the user to hold down a key on their keyboard, and when they then click, they just .append whatever they just clicked into the same form field.
Here's my jQuery-code I'm using for the first/default scenario:
$(function(){
$('ul#filter-results li').click(function(){
var from = $(this).attr('id'); // get the list ID and
$('input#search').val(from+' ').keyup(); // insert into text-field then trigger the search and
$('input#search').focus(); // make sure the field is focused so the user can start typing immediately
});
});
Is there a way to implement some sort of keyboard key-listener?
Something like:
if (e.shiftKey){
.append('this text instead')
}
haven't tried out to see if shiftKey is even any valid name here
shiftKey is of one of the properties of the event object and is valid to be used. try this:
$(document).on('keyup click', function(e){
if (e.shiftKey) {
$('input#search').focus()
$('input#search').val(e.target.id)
}
})
DEMO
$('ul#filter-results').on('click', 'li', function(e) {
if(e.shiftKey) {
do something;
} else {
do something else;
}
});
There is a jQuery plugin for extended click.
You could try that or see how they have done it and implement it yourself.
ExtendedClick plugin
Hope this helps.
This is what I ended up with:
I switched over to altKey because shiftKey marked a lot of text when I clicked.
Didn't do anything besides it doesn't look good...
$(function(){
$('ul#filter-results li').click(function(e){
var text = $(this).attr('id'); // get the ID
var input = $('#search'); // form field to insert text into
if (e.altKey){ input.val(input.val()+', '+text+' ').keyup(); } // fetch whatever is already there, and add some more
else { input.val(text+' ').keyup(); } // just replace whatever is already there
$('#search').focus();
});
});
Thanks for good suggestions...

save() method on datasource does not fire querySave/postSave events

My save button uses SSJS with some logic. I want to save datasource, so I use
document1.save();
Script works, but querySave/postSave code is not executed.
Only workaround is to use simple action and divide button event to blocks for "execute script", "Save document (simple action)" and "execute script" (just to return "navigation" string).
Is it possible to save datasource in SSJS and fire qS/pS events?
please try this SSJS code:
var dsName = "document1.DATASOURCE";
var app = facesContext.getApplication();
var ds = app.getVariableResolver().resolveVariable(facesContext, dsName);
ds.save( facesContext, true );
The variable dsName contains the name of your datasource followed by ".DATASOURCE". To use it f.e. with current document, you have to change to "currentDocument.DATASOURCE".
Hope this helps
Sven
Sven what is the difference between your code and currentDocument.save() is something else happening than querysave and postsave?

Getting the dijit for a typeAhead in XPages

I want to be able to add an onBlur/onkeypress/onChange events to all TypeAhead fields on the form rather than have a developer select every one in the Designer client. The only thing I cannot get a handle on is the onChange event.
When the user selects something in the TypeAhead the onChange event is triggered when adding the code directly to the event in the Domino Designer - so I should be able to replicate that capability with code.
If my typeAhead field is called inputText2 I thought I would be able to do the following
var widget = dojo.byId("#{id:inputText2}")
dojo.connect(widget, 'onChange', function (){
alert('1')
});
However this doesn't appear to work...
I tried lowercase onchange
var widget = dojo.byId("#{id:inputText2}")
dojo.connect(widget, 'onchange', function (){
alert('1')
});
no luck there either
I tried
var widget = dijit.byId("#{id:inputText2}");
but that failed to event select the element entirely
So what do I need to do to trigger the onchange event when selecting an option in the typeAhead?
I found a solution.....not ideal but it worked for the moment - not generic though, but a start
Copying the way XPages does it....add this to the page
function view__id1__id2__id31__id50_clientSide_onchange(thisEvent) {
alert('me')
}
and then
dojo.addOnLoad(function(){
XSP.addOnLoad(function() {
XSP.attachEvent("X1","view:_id1:_id2:_id31:inputText2", "onchange", view__id1__id2__id31__id50_clientSide_onchange, false, 2);
});
});
});
X1 must be unique but everything else can be calculated
Thanks to Serdar Basegmez

Resources