Is it possible to use jQueryUI Datepicker instead of the w2ui builtin date picker? - w2ui

I am using jqueryUI datepicker through out my app, and would like to use that in one of the date fields on a w2popup or w2form. I've tried $('#field-id').datepicker() after I open the form, but it does not work.
Is there a way to make that work?

You can't apply the jQueryUI datepicker to a w2ui date field, because there's no way to prevent the w2ui date popup from openening.
You can however apply the jQueryUI datepicker to a "normal" w2ui field, so you can have the w2ui look and feel on the field and also use the datepicker.
Note that when using w2ui layout/forms, you're most likely already using a z-index, whether you want or not, while jQueryUI's datepicker has a default z-index of 2.
To circumvent this, you can set the z-index as follows:
<p>Date: <input type="text" id="datepicker"></p>
<script>
$(function() {
$( "#datepicker" ).datepicker({
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
}).w2field('text');
});
</script>
Or you could write your own w2ui field that opens a jQueryUI datepicker:
http://w2ui.com/web/docs/form/fields-custom

Related

Two datepicker in one declaration bootstrap-datepicker

I am using Datepicker for Bootstrap v1.6.4 in my asp.net mvc application.
This is my code to show the date:
HTML:
<div id="datepicker"></div>
JavaScript:
$input = $("#datepicker");
$input.datepicker({
format: 'dd MM yyyy'
});
$input.data('datepicker').hide = function () { };
$input.datepicker('show');
As I want to show full datepicker selection but in output it is showing me two datepickers.
OUTOUT:
Don't have any solution anywhere I have searched a lot and this behavior is also awkward don't know but this should ideally not happen but in my case, it is happening.
Any solution will be appreciated.
Thanks in advance.

TinyMCE - preserve style and function of selected element

I have decided to 'enhance' a textarea in a form with TinyMCE... however, doing so has interrupted the styling and jQuery functionality of the original element, as TinyMCE wraps that element in an iframe and a few divs. What I'd love to be able to do is to get the TinyMCE functionality (preserving text formatting, etc.) but not lose the styling and functions that I had associated with the original textarea. I looked through the TinyMCE documentation, but couldn't seem to find anything about this. Does anyone have any thoughts on how to accomplish this?
My form features the textarea like so:
<head>
<script>tinymce.init( { selector: 'textarea' } );</script>
</head>
<div class="form-element">
<div class="label-container">
<label for="body">Post</label><span class="warning">Please fill out this field</span>
</div>
<textarea id="body" class="input-field" name="body"></textarea>
</div>
but adding TinyMCE breaks the label/textarea relationship.
Also, jQuery functionality is broken, such as this validation script:
$("form").submit(function(e){
tinyMCE.triggerSave();
var inputFields = $(".input-field");
var proceed = true;
for(var i = 0; i < inputFields.length; i++){
if($(inputFields[i]).val() == ""){
$(inputFields[i]).css("border", "solid 3px #E86F3A");
$(inputFields[i]).prev().find(".warning").show();
var proceed = false;
e.preventDefault();
}
else{
$(inputFields[i]).css("border", "none");
$(inputFields[i]).prev().find(".warning").hide();
};
};
//OTHER STUFF...
});
since the textarea.input-field is no longer picked up in the inputFields variable.
So, in a nutshell, I'm looking for the TinyMCE wrapper to 'inherit' the styling and functionality of the element that it is attached to. Possible?
As you have correctly surmised when you invoke TinyMCE on a <textarea> the original <textarea> is no longer visible on the page and its replaced by an <iframe> and series of <div> elements.
If you want to keep the underlying <textarea> in sync you can use the tinymce.triggerSave() method. This will update all of the underlying <textarea> elements with the current value of the appropriate instance of TinyMCE.
You can do this when someone tries to save/submit the content or you can try to perform this when certain editor events happen (https://www.tinymce.com/docs/advanced/events/#editorevents). Unless you need real time accuracy of the contents of the <textarea> its far easier to call the triggerSave() method right before you perform you jQuery validation.
Note: Putting a border on the <textarea> won't have any impact on TinyMCE as you no longer see the underlying <textarea>. You can certainly try to add CSS to the editor's HTML in real time. The outer border of TinyMCE 4.4 has these classes attached:
class="mce-tinymce mce-container mce-panel"
...but do note that these classes could change over time so if you upgrade TinyMCE check to make sure your CSS still works before upgrading.

Lock/unlock form with toggle

I'm looking for a way to have a button toggeling the field of my form. When "locking" the form with the toggle button no data can be typed. When "unlocking" data should be allowed to be typed. What I want to achieve with this is simple avoiding users to accidentally type.
I found the code below and it works. Only problem is that it only applies to one input field. I want it to work on more that one.
<input type="checkbox" id="yourBox">
<input type="text" id="yourText">
<script>
document.getElementById('yourBox').onchange = function() {
document.getElementById('yourText').disabled = this.checked;
};
</script>
Mark the fields you want to disable with a CSS class, and then use jQuery to disable them.
jQuery - Disable Form Fields
If you want a pure Javascript solution, just repeat this line
document.getElementById('yourText').disabled = this.checked;
for each field.
Or, you can do something like this this: How to Get Element By Class in JavaScript?. Note that you can assign multiple CSS classes to the same field, so assign another class to identify those fields that need to be disabled.

date picker on jsoup

I need to post the date for datepicker, but i don't know how to. I just know about post the value of textbox and button using jsoup, but how about datepicker? It doesn't have input name like others. Can you give an example how to post the date from datepicker using jsoup? Many thanks.
This is the code for post the value of textbox and button, but i dont know how to post the value of datepicker.
Document document = Jsoup.connect("http://example.com/somescript").data("text1", "yourText1Value")
.data("button1", "Submit")
.post();
Datepicker field is just a simple input type="text" like this : <input id="datepicker" class="hasDatepicker" type="text">
so something like this should do:
Document document = Jsoup.connect("http://example.com/somescript").data("datepicker", "08/14/2012") .data("button1", "Submit") .post();

Jquery Selector Multiple Classes (this)

I have a page that lists content that are contained in a div with a class ad-container. in that container there is a hidden div with the class ad-contact. on the hover of the ad class i want to animate the display of ad-info. since there are multiple ads on a paticular page, i want only the ad-info of the currently hovered ad-container to slide in. my problem is that since there are more than 10 ads a page when you hover over any of the ads, all of the ads-contact divs slideDown and not the one you are hovering over.
$(document).ready(function() {
$('.ad-container').hover(
function(){
$(".ad-contact").slideDown(1000);
},
function(){
$(".ad-contact").slideUp(1000);
});
});
i think, (this) is used here but im not sure. and this would really shed the light for me.
<div class="ad-container">
<div class="ad-title">title<span class="ad-title-img">(pic)</span></div>
<div class="ad-description">texttext</div>
<div class="ad-contact" style="display:none">contact poster</div>
<div class="ad-sellerinfo" style="display:none">* Verified ***-****<br />
Paid Member</div>
</div>
The jQuery constructor accepts a 2nd parameter which can be used to override the context of the selection. Something like this should work:
$(document).ready(function() {
$('.ad-container').hover(
function(){
$(".ad-contact", this).slideDown(1000);
},
function(){
$(".ad-contact", this).slideUp(1000);
});
});
Also, worth mentioning, $(".ad-contact", this) is internally converted into: $(this).find(".ad-contact") so you can use this one instead, it might be slightly faster.
You could use the .children() selector:
$(this).children(".ad-contact").slideDown(1000);
This way you will only act on the class ad-contact if its a child of the object in context (which is the object currently being hovered)
See a working demo here
You should use event to handle this,
First you need like
ad-container.hover(function(event){
event.target.children();
})
and then this.show().delay(1000).hide();
the code sample provide may not work when copy paste you have to write your own code in editor.