jquery

widgetVar cannot be used in p:fileUpload

守給你的承諾、 提交于 2021-02-16 18:51:29
问题 I want to remove the error message when choosing a wrong type of file. I followed the link http://forum.primefaces.org/viewtopic.php?f=3&t=23853 . <p:fileUpload fileUploadListener="#{userProfileUpdateController.upload}" widgetVar="fileuplaodWgt" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" description="Select Images" update="userPhoto" mode="advanced"/> and I import <h:outputScript name="library.js" library="script"></h:outputScript> In library.js $(document).ready(function(){ alert(fileuplaodWgt);

Add html to div without replacing the current content in it

痞子三分冷 提交于 2021-02-16 18:40:10
问题 I'm trying to add dhtml to the div with the id upload_results. That should work without replacing the current content in the div. The Code: (interesting part is at the bottom) <script language="JavaScript"> function do_show() { $("#webcamContainer").fadeIn(''); } webcam.set_hook( 'onComplete', 'my_completion_handler' ); function do_upload() { upload to server document.getElementById('upload_results').innerHTML = '<div>Uploading...</div>'; webcam.upload(); } function my_completion_handler(msg)

jQuery accordion - how to collapse other open accordion panes when another one is opened

拟墨画扇 提交于 2021-02-16 18:38:33
问题 I have an accordion that I want to have the following functionality: when the user clicks on a link to expand, the other expanded links (if any) will collapse. I know this functionality is built in the accordion plugin, but I'm trying to avoid adding another library (jQuery UI). EDIT: Here is the code I have right now (here it is on jsFiddle: http://jsfiddle.net/s2Jfs/2/): $('.accordion-toggler').addClass('toggle-plus'); $('.accordion-toggler').click(function() { $this = $(this); if($this

When is it proper to add a return at the end of a JavaScript function?

梦想与她 提交于 2021-02-16 17:59:50
问题 I have seen some developers place a return at the end of their JavaScript functions like this: $(".items").each(function(){ mthis = $(this); var xposition = some .x() position value; if(xposition < 0){ mthis.remove(); return; } }); Is having a return even necessary? I know that return false cancels out of a loop early and I know that return x , returns a value, but having just return??? What does that mean? Sorry - I forgot to put an end } at the very end of the code. the return is in the if

Post array via jQuery

為{幸葍}努か 提交于 2021-02-16 17:59:05
问题 I have a form which contains some unique input fields and some others with duplicate names, like this: <form method="post"> Title: <input type="text" name="title" /><br /> Content: <input type="text" name="content" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email" /><br /> Name: <input type="text" name="name" /><br /> Email: <input type="text" name="email"

Jquery inserting unicode instead of symbol

℡╲_俬逩灬. 提交于 2021-02-16 16:12:47
问题 i'm looking in a way to make a really basic wysiwyg such as when a user lick the button, it insert the symbol ♂ ( ♂) It is working but there is two problem : 1 - Only the unicode characters are inserted, they are not converted into symbol ( ♂) 2- If you have time, is there a simple way to insert the symbol where the "text cursor"is and not at the end of the content of the textarea ? Thanks for your help http://jsfiddle.net/cdjEr/3/ 回答1: ♂ is an HTML escape code. It is only processed in HTML

CountDown timer PHP/JavaScript

白昼怎懂夜的黑 提交于 2021-02-16 16:12:25
问题 Hi I have a JavaScript for countdown which is selecting time form MySQL and it is working fine on (Chrome, Firefox), but on (IE and Safari) it is returning "NaNd NaNh NaNm NaNs". I have attached my code below. <?php $con = mysqli_connect("localhost", "root", "", "timer") or die("Error Could not connect to the database Sir." . mysqli_error($con)); $query = mysqli_query($con, "SELECT * FROM counter WHERE id = 1") or die(mysqli_error($con)); $row = mysqli_fetch_array($query)or die(mysqli_error(

How use JQuery $(this) in javascript Classes

≡放荡痞女 提交于 2021-02-16 15:25:52
问题 When I write jQuery code, I use $(this) to change element: $('.classname').click(function(){ $(this).toggleClass('collapsed'); // .. }); Now I have are javascript class, looks like this: class CabinetFormSize { constructor() { this.cabinetBTN = $(".cabinetBTN"); this.events(); } events() { this.cabinetBTN.click(this.toggleMenu.bind(this)); } toggleMenu() { console.log($(this)); this.cabinetBTN.toggleClass('d-none'); } } If i write this in toggleMenu() I have class instance, but I need the

How to change video source onclick?

时光总嘲笑我的痴心妄想 提交于 2021-02-16 15:19:45
问题 HTML: <div class="source" id="source_one" onclick="chnageToSourceTwo()"> Source 1 </div> <video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="none" width="640" height="360" poster="" data-setup="{}"> <source src="example_video_1.mp4" type='video/mp4' /> </video> Script: function chnageToSourceTwo() { document.getElementById("example_video_1").src="example_video_2.mp4"; } The video source is not changing after clicking on div. I am using the

Php post not getting the html input element value which append by jquery

三世轮回 提交于 2021-02-16 15:17:37
问题 I have page which user can add date range from, to and price. By default there is three, but user can add more ranges using the add date range button button. My problem is, after adding a few extra date ranges when I get the $_POST value it is not showing the appended html element's post values. javascript part var n = 0; $(document).ready(function () { $("#btn2").click(function () { $("#add_drange").append(" <p><input type='text' name='from" + n + "' class='datepicker' placeholder='From' />