Kendo UI Tabstrip and jQuery Tooltipster Overlapping issue - css

I'm using MVC4,Kendo tabstrip along with jQuery Tooltipster for showing validation messages.
My issue is the validation message from Tab 1 is getting overlapped on Tab 2 due to z-index. I have tried setting z-index for tooltipster-base but isn't working.
My HTML code looks like something this:
<div id="tabstrip">
<ul>
<li>Tab 1</li>
<li>Tab 2</li>
</ul>
<div><form id="myform">
<input type="text" name="field1" />
<input type="text" name="field2" />
<br/>
<input type="submit" />
</form></div>
<div><form id="myform2">
<input type="text" name="field3" />
<input type="text" name="field4" />
<br/>
<input type="submit" />
</form></div>
</div>
Script:
$(document).ready(function () {
var tabstrip = $("#tabstrip").kendoTabStrip().data("kendoTabStrip");
tabstrip.select(0);
// initialize tooltipster on text input elements
$('#myform input[type="text"]').tooltipster({
trigger: 'custom',
onlyOne: false,
position: 'right'
});
$('#myform2 input[type="text"]').tooltipster({
trigger: 'custom',
onlyOne: false,
position: 'right'
});
// initialize validate plugin on the form
$('#myform').validate({
errorPlacement: function (error, element) {
$(element).tooltipster('update', $(error).text());
$(element).tooltipster('show');
},
success: function (label, element) {
$(element).tooltipster('hide');
},
rules: {
field1: {
required: true,
email: true
},
field2: {
required: true,
minlength: 5
}
},
submitHandler: function (form) { // for demo
alert('valid form');
return false;
}
});
// initialize validate plugin on the form2
$('#myform2').validate({
errorPlacement: function (error, element) {
$(element).tooltipster('update', $(error).text());
$(element).tooltipster('show');
},
success: function (label, element) {
$(element).tooltipster('hide');
},
rules: {
field3: {
required: true,
email: true
},
field4: {
required: true,
minlength: 5
}
},
submitHandler: function (form) { // for demo
alert('valid form');
return false;
}
});
});
Please check this:
JSFiddle: http://jsfiddle.net/vishalvaishya/bCZWd/2/
Please help me for setting proper css style.

Found solution myself only. Might be helpful for someone.
Done some updation in tooltipster logic.
Added extra option (appendTo) to place tooltip over specific element only:
c = {
animation: "fade",
appendTo: "body",
arrow: true,
...
And changed parameter of tooltipster.appendTo('body') in showTooltip function like;
tooltipster.appendTo($(l.options.appendTo));
Usage:
$('#profileForm input[type="text"]').tooltipster({
trigger: 'custom',
onlyOne: false,
position: 'right',
appendTo: '#profileForm'
});
Like this you can use tooltipster on different kendo-tabs or on different divs.
See on JSFiddle:
Previous : http://jsfiddle.net/vishalvaishya/bCZWd/2/
Working : http://jsfiddle.net/vishalvaishya/bCZWd/3/

Related

Close modal with search results when clicking outside?

I'm trying to close a modal div with AJAX search results, but nothing works.
I have tested several solutions on SO but nothing works?!
This is the code I have right now:
<form action="/search" method="get">
<input type="hidden" name="qt" value="main">
<div class="searchBox" id="search">
<input type="text" name="q" id="find" placeholder="Search here..." class="mainSearchField" />
<div class="searchBoxResults" id="search_items"></div>
</div>
</form>
<script>
$(document).ready(function() {
$( "#find" ).keyup(function(){
fetch();
});
});
function fetch() {
var val = document.getElementById("find").value;
$.ajax({
type: 'post',
url: '/include/functions/searchFetch.php',
data: {
q:val
},
success: function (response){
document.getElementById("search_items").innerHTML = response;
}
});
}
</script>
UPDATE
This is what I have tried to add, to the above:
window.onclick = function(event) {
if (event.target.id != "search_items") {
$("search_items").hide();
}
}

React - Ant Design 4 Form InitialValues / form.setFieldsValue

I tried it also with the "Form initialValues={system}" but the Input fields are still empty. My object has only string values.
Why cant the setFieldsValue or the initialValues read my object?
const ResetFields = () => {
form.resetFields();
form.setFieldsValue({
'name': 'Test', //working
'street': system.street, //not working (type is string)
houseNumber: system.houseNumber, //not working (type is string)
postCode: system.postCode,
city: system.city
});
}
return (
<div>
<Form
{...layout}
size={"large"}
form={form}
validateTrigger="submit"
onReset={ResetFields}
onFinish={Submit}
validateMessages={validateMessages}
>
<Form.Item
name='name'
label="Name"
rules={[{ required: true }]}
>
<Input autoComplete="off" />
</Form.Item>
//More Form.Item and Buttons Submit and Reset...
</Form>
</div>
);
I had a similar issue, try this. maybe that will help.
'street': system?.street

bootstrap-tables onRefresh event not working

Any idea why the onRefresh event is not firing? First time through the table displays properly. But when clicking the refresh button it does not work (event does not fire). I thought this worked before, but I think a new version of bootstrap.min.js may have killed it (or perhaps it is just a coincidence). Any help would be helpful.
HTML:
<table id="stats-view-output4" data-pagination="false" data-show-refresh="true" data-search="false"
data-cache="false" data-show-toggle="false" data-show-columns="false"
data-show-header="false" data-show-footer="false">
</table>
Javascript (a button gets u to this function):
function do_trader_instruments() {
$('#stats-view-output4').bootstrapTable({
onRefresh: function (params) {
bpt_pie_chart();
},
columns: [{
field: 'TradedInstruments',
title: 'Traded Instruments'
}],
data: [{
TradedInstruments: "<div id='instrument-chart'></div>"
}]
});
bpt_pie_chart();
}
Well, I gave up and did a brut force solution. Feels like a bug of a conflict somewhere. For anyone stumbling onto this here it is:
HTML:
<div id="toolbar4">
<div class="form-inline" role="form">
<button id="refresh4" class="btn btn-default" type="submit"><span class="glyphicon glyphicon-refresh"></span></button>
</div>
</div>
<table id="stats-view-output4" data-pagination="false" data-show-refresh="false" data-search="false"
data-cache="false" data-show-toggle="false" data-show-columns="false"
data-toolbar="#toolbar4" data-toolbar-align="right"
data-show-header="true" data-show-footer="false" style="font-size:11px;">
</table>
Javascript:
$(function () {
$('#refresh4').click(function () {
bpt_pie_chart();
});
});
function do_trader_instruments() {
$('#stats-view-output4').bootstrapTable({
columns: [{
field: 'TradedInstruments',
title: 'Traded Instruments'
}],
data: [{
TradedInstruments: "<div id='instrument-chart'></div>"
}]
});
bpt_pie_chart();
}

tinymce v4 jquery: how to catch onkeyup?

I'm trying to enable submit button when some form fields are filled. I've found a piece of javascript code that works, but I've a problem with textarea fiel which is tranformed by tinymce... How to catch it?
My html:
<form id="form_id1">
<fieldset>
<legend>Personal</legend>
Name: <input type="text" size="30" /><br />
Email: <input type="text" size="30" /><br />
Date of birth: <input type="text" size="10" /><br />
Address : <textarea size="30"></textarea><br />
</fieldset>
<input type="submit" value="Submit" />
</form>
My javascript:
$(document).ready(function()
{
$('#form_id1 input:submit').attr("disabled", true);
var textCounter = false;
$('#form_id1 input:text, #form_id1 textarea').keyup(check_submit);
function check_submit() {
$('#form_id1 input:text, #form_id1 textarea').each(function()
{
if ($(this).val().length == 0) {
textCounter = true;
return false;
}
else {
textCounter = false;
}
});
$('#form_id1 input:submit').attr("disabled", textCounter);
}
});
My tinymce init:
tinymce.init({
selector: "textarea",
language: 'fr_FR',
image_advtab: true,
menubar:false,
forced_root_block: false,
plugins: ["link","code","media","image","textcolor", "emoticons"],
toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons",
});
Thanks
In tinymce init add:
setup: function(ed) {
ed.on('keyup', function(e) {
console.log('Editor contents was modified. Contents: ' + ed.getContent());
check_submit();
});
}
Keep in mind you might need to find your editor instance rather than the textarea to get the actual value. If you made the textarea have id="textarea-tiny-mce"
tinymce.get('textarea-tiny-mce').getContent();
window.onload = function () {
tinymce.get('content').on('keyup',function(e){
console.log(this.getContent().replace(/(<[a-zA-Z\/][^<>]*>|\[([^\]]+)\])|(\s+)/ig,''));
});
}
tinymce.init({
setup: function (editor) {
editor.on('keyup', function (e) {
console.log(e);
//custom logic
});
}
});
Please make below changes in tinymce.init
tinymce.init({
selector: "textarea",
setup: function(editor) {
editor.on('keyup', function(e) {
console.log('edited. Contents: ' + editor.getContent());
check_submit();
});
}
language: 'fr_FR',
image_advtab: true,
menubar:false,
forced_root_block: false,
plugins: ["link","code","media","image","textcolor", "emoticons"],
toolbar: "bold italic forecolor backcolor alignleft aligncenter alignright alignjustify link unlink image media emoticons",
});
See the below reference for more details.
https://www.tiny.cloud/docs/advanced/events/

Data binding not working but works fine in tutorial

I am new to knockout.js. I am following this tutorial. It is working fine on knockout site but not for me. Error console is also not showing any error.
Below is my code
View:
Tasks
<form data-bind="submit: addTask">
Add task: <input data-bind="value: newTaskText" placeholder="What needs to be done?" />
<button type="submit">Add</button>
</form>
<div >
<ul data-bind="foreach: tasks, visible: tasks().length > 0" id="testing">
<li>
<input type="checkbox" data-bind="checked: isDone" />
<input data-bind="value: title, disable: isDone" />
Delete
</li>
</ul>
</div>
View Model:
<script>
function Task(data) {
this.title = ko.observable(data.title);
this.isDone = ko.observable(data.isDone);
}
function TaskListViewModel() {
// Data
var self = this;
self.tasks = ko.observableArray([]);
self.newTaskText = ko.observable();
self.incompleteTasks = ko.computed(function() {
return ko.utils.arrayFilter(self.tasks(), function(task) { return !task.isDone() });
});
// Operations
self.addTask = function() {
self.tasks.push(new Task({ title: this.newTaskText() }));
self.newTaskText("");
};
self.removeTask = function(task) { self.tasks.remove(task) };
}
ko.applyBindings(new TaskListViewModel(),document.getElementById("testing"));
</script>
The problem is that the ko.applyBindings doesn't apply to all data-bind attributes. Move your "testing" id to a place where it covers all the HTML code with the relevant "data-bind" attributes.

Resources