Use Kendo UI switch in a web application - kendo-ui

I am trying to use a Kendo mobile widget - switch in my web application as below:
<input id="btnConvert" type="checkbox" onclick="onChange();" />
$(document).ready()
{
$("#btnConvert").kendoMobileSwitch({
onLabel: "UK",
offLabel: "US"
});
}
function onChange(e) {
alert(e.checked);//true of false
}
But its not firing the click event. i tried the onchange event which is also not working.
Also i tried
$('input:checkbox').change(function () {
}
but no success...

Define a change handler event in your switch definition.
$("#btnConvert").kendoMobileSwitch({
onLabel: "UK",
offLabel: "US",
change : function (e) {
alert("You changed the value");
}
});
See the documentation here.

Related

Extjs4 add click event to a container and handle it in a controller

{xtype : 'container',
id:'leaderPhotoContainer',
listeners:{click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(e,panel,obj){ //click function
console.log('click el'); //It will work.
obj.fireEvent('click');
//if I adding my code here ,it is worked ,but I want to fire this event to the controller ,and be handled there.
//How I can get the 'container' here ?
//container.fireEvent('click') I guess it will work.
}
}}}
Can someone help me? Thank you.
listeners:{click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(e,panel,obj){ console.log('click el');
this.down('#leaderPhotoContainer').fireEvent('click');
}
,scope:this//It must be a upper container.
}
Maybe It is a silly way to slove it,but It is worked . Is there a better way?
You can bind your event in your controller.
//...
init: function () {
this.control({
'yourpanel': {
afterrender: function(panel) {
panel.mon(panel.el, 'click', this.foo);
}
}
});
},
foo: function() {
console.log('Foo');
}
//...

TinyMCE setcontent in Joomla wont set the content in tinymce after jQuery(document).ready(function()

When I do at the bottom of a view and after some html:
jQuery(document).ready(function() {
tinyMCE.activeEditor.setContent("asdsad");
});
I get an Error in firefox
Error: TypeError: tinyMCE.activeEditor is null
When I add the line in a function and activate it after a click event, the code works, for example
<input type="button" onclick="setcontent()" value="Set the content" >
<script>
function setcontent(){
tinyMCE.activeEditor.setContent("asdsad");
}
</script>
I am thinking that TinyMCE has not finished loading after jQuery(document).ready ? or am I missing something here?
There's a handler for inserting text for every editor plugin in Joomla
Try jInsertEditorText('hello world', 'jform_articletext');
where second argument is the id of JForm editor field (for com_content it's jform_articletext). This way you are able to insert content to whatever editor is currently used (tinyMCE, codemirror ...).
you can try this
jQuery(document).ready(function() {
if (window.tinyMCE && window.tinyMCE.activeEditor)
{
tinyMCE.activeEditor.setContent("asdsad");
}
});
Or
you can initialize tinyMCE and then setContent
tinyMCE.init({
mode : "exact",
elements : "updateeditor",
theme : "advanced",
plugins : "inlinepopups, example",
theme_advanced_buttons3_add : "example",
});
tinymce.init({
...
setup: function(editor) {
editor.on('init', function(e) {
console.log('init event', e);
});
}
});
http://www.tinymce.com/wiki.php/api4:event.tinymce.Editor.init

Sencha Touch - how to prevent a datepicker from hiding?

I'm using an Ext.picker.Date and I have some checks I run on the hide event. However, if a certain criteria is met, I want to stop the process and have the date picker not hide.
I've tried using the beforehide event, and running my code there, but that event doesn't seem to fire.
Below is the config for my datepicker. If the condition is true, how can I stop the picker from hiding?
Thanks for any help.
var datePicker = new Ext.picker.Date({
docked: "bottom",
listeners: {
beforehide: function() {
console.log("before hide");
},
hide: function() {
if (1 == 1) {
//how do I stop the picker from hiding?
Ext.Msg.alert("You cannot select that date.");
}
}
},
slotOrder: ["day", "month", "year"],
useTitles: false
});
this.add(datePicker);
Are you using Sencha Touch 2? I'm going to assume so, since you're using Ext.picker.Date.
According to the documentation, the date picker doesn't fire a beforehide event:
Sencha Docs
What you really want to do here is insert some logic after 'Done' is tapped and before the picker hides itself. The picker calls onDoneButtonTap internally; you can inject your own logic like so:
Ext.define('MyApp.widget.DatePicker', {
extend: 'Ext.picker.Date',
xtype: 'mypicker',
onDoneButtonTap: function() {
if (1 == 1) {
Ext.Msg.alert("You cannot select that date.");
} else {
Ext.picker.Date.prototype.onDoneButtonTap.call(this);
}
}
});
this.add({
xtype : 'mypicker',
docked : "bottom",
slotOrder : ["day", "month", "year"],
useTitles : false
});
This is assuming that your logic will be able to access what it needs within the scope of the date picker. If this isn't the case, you can pass additional configuration to the date picker when you create it...maybe something like acceptedDateRange {...}
The simplest way could be:
var datePicker = new Ext.picker.Date({
docked: "bottom",
slotOrder: ["day", "month", "year"],
useTitles: false,
onDoneButtonTap: function() {
if (1 == 1) {
Ext.Msg.alert("You cannot select that date.");
} else {
Ext.picker.Date.prototype.onDoneButtonTap.call(this);
}
}
});
this.add(datePicker);
I think defining your own class like in the first example is the way to go, especially in situations where you inject logic into existing framework code and when you use the component in more than one place. But the second example will work as well.

JQGrid - How can I Create Check box in Navigation to Trigger Multiselect or SingleSelect

function bind_single_select() {
if (!$("input#single").length > 0) {
$("span.single_select").prepend("<input type='checkbox' name='single' id='single' checked='checked' style='vertical-align:middle' />");
}
$("table#gridTable").find("tr").click(function () {
if ($("input#single").attr("checked")) {
$(".trSelected").removeClass("trSelected");
$(this).addClass("trSelected");
}
});
}
I found this in Flexigrid but in JQGrid How can I do it.
Another Question :
.navButtonAdd('#pager',
{ caption: "Add",
buttonimg: "/Areas/Pages/Content/Images/add.png",
onClickButton: function () {
PopupCenter('<%= Url.Action("CreatePublisher","Publisher") %>',
'CreatePublisher', '500', '300');
}, position: "last"
})
the buttonimg is not work even I use
ui-icon-plus
Thanks in Advance.
The second part of your question is very easy to answer. The parameter buttonimg is no more supported in the navButtonAdd function. You should use buttonicon instead. An example you can find here. In general as a value of buttonicon you can use any from the jQuery UI Framework Icons.
To toggle multipleSearch parameter you can just define search parameters of navGrid separately and toggle the value of the multipleSearch property. To make all more easy I suggest to use an additional parameter recreateFilter:true.
var grid = jQuery('#list');
var pSearch = { multipleSearch:false, recreateFilter:true };
grid.jqGrid({
// all jqGrid parameters
}).jqGrid ('navGrid', '#pager', {edit:false, add:false, del:false, refresh:true, view:false},
{},{},{},pSearch));
$("#pager_left table.navtable tbody tr").append ( // here 'pager' part or #pager_left is the id of the pager
'<td><div><input type="checkbox" class="myMultiSearch" id="navMultiSearch"/>Multi-Search</div></td>');
$(".myMultiSearch").change(function() {
if ($(this).is(':checked')) {
pSearch.multipleSearch = true;
$(".myMultiSearch").attr("checked","checked");
}
else {
pSearch.multipleSearch = false;
$(".myMultiSearch").removeAttr("checked");
}
});
On the small demo I inserted both internal and external checkboxes to the navigation bar and a custom button additionally:

Making the JQuery Validation plugin evaluation non-lazy

According to the documentation for the JQuery validation plugin:
the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages
Is there any way to display the messages as the user tabs through the form?
Cheers
You can override the default onfocusout to do more eager/pre-submit validation you want, like this:
$(function() {
$("form").validate({
rules: { ...rules... },
messages: { ...messages... },
onfocusout: function(element) { $(element).valid(); }
});
});
The default onfocusout looks like this, disabling the blur validation until after it's been submitted once:
onfocusout: function(element) {
if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
this.element(element);
}
}

Resources