Unnamed: 0
int64 302
6.03M
| Id
int64 303
6.03M
| Title
stringlengths 12
149
| input
stringlengths 25
3.08k
| output
stringclasses 181
values | Tag_Number
stringclasses 181
values |
---|---|---|---|---|---|
1,350,491 | 1,350,492 |
Pass form variables on to second postback...asp.net
|
<p>Is it possible to postback to the server, perform a function, and then continue that postback on to an external place? (ie, to a payment system)</p>
<p>(the scenario is clicking a button to place an order, mark it as sent, then send them off to the payment page (there are form variables that needs to be sent to the payment screen as well))</p>
|
c# asp.net
|
[0, 9]
|
3,822,468 | 3,822,469 |
Remove item[i] from jQuery each loop
|
<p>How do I remove an item[i] from items once it reaches in:</p>
<pre><code>$.each(items, function(i) {
// how to remove this from items
});
</code></pre>
|
javascript jquery
|
[3, 5]
|
2,847,660 | 2,847,661 |
Image scrolling twice in jquery carouFredSel-5.6.4
|
<p>I am having two issues with my website code. </p>
<p>Link: <a href="http://coding.designzzz.com/demos/bakery-site/" rel="nofollow">http://coding.designzzz.com/demos/bakery-site/</a></p>
<p>First with my slider right arrow click it will scroll 2 images at a time. I only want it to scroll 1 image at a time. </p>
<p>Second- In Chrome my slider does not work properly. It seems to have some height issue and is not properly visible.</p>
<p>Please give me some suggestions that might help fix my problems.</p>
|
javascript jquery
|
[3, 5]
|
397,078 | 397,079 |
issue in numeric validation javascript
|
<p>I am using a phone number field in my web page. I need to check whether the value entered in that field should numeric and 10 digit number. For that i used the following code.</p>
<pre><code>var phonead;
function checkphonead(int){
var filter=/^[0-9]{10}$/;
if (filter.test(int)) {
phonead = true;
}
else {
phonead = false;
}
return phonead;
}
if(document.admission_form.phone.value=='') {
alert("Please enter your phone number");
document.getElementById('phone').focus();
return false;
}
if(checkphonead(document.getElementById('phone').value) == false) {
alert("Please enter a 10 digit phone number!");
document.getElementById('phone').focus();
return false;
}
</code></pre>
<p>If I submit the form with any phone number it just saved as <code>2147483647</code> in the database. If I remove the above script, the correct phone number value has saved in the database. I couldn't trace why it happens. Any suggestion?</p>
|
php javascript
|
[2, 3]
|
1,765,671 | 1,765,672 |
How do I call a function on confirmation of leaving page?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1299452/how-do-i-stop-a-page-from-unloading-navigating-away-in-js">How do I stop a page from unloading (navigating away) in JS?</a> </p>
</blockquote>
<p>I've created an online whiteboard. I wish to confirm from user whether he wants to leave the page or not (since he needs to save whiteboards before leaving)<br/></p>
<pre><code>$(window).bind('beforeunload', function(){
return 'Are you sure you want to leave?';
});
</code></pre>
<p>Now I need to call a function if the user confirms to leave the page. That function will post to the DB from jQuery (which I know how to do) & convert the user from active to inactive.
<br/>
Only trouble I'm having is <b>how do i get that function to be executed when the user CONFIRMS to leave.</b>
<br/>
Thanks!<br/></p>
<hr>
<p>FURTHER...<br/></p>
<pre><code>$(window).bind('beforeunload', function(){
return 'Are you sure you want to leave?';
});
window.onunload=pageleave();
function pageleave() {
var grp=$("#grpid").val();
var login=$("#loginid").val();
$.ajax({
type: 'POST',
url:'collwb_pageleave.php',
data: { GrpID:grp, LogID:login },
cache:false,
});
}
</code></pre>
<p><br/>
Here what happens is, on page load, pageleave gets executes and make Activity=0 in the Database. This should happen on page unload... Why? Why would this happen?</p>
|
javascript jquery
|
[3, 5]
|
2,446,791 | 2,446,792 |
Using $.post to authenticate user to return custom error / success message
|
<p>I am having this jQuery to authenticate users into site, how can I make two actions for success/error returned by login.php? Is it possible to refresh the page on success (for example) and post error message if the login info was not successful in login.php. I hope my question is clear. Here is the code. Right now it just paste the data output from login.php and I do not know how to seperate success/error returned server side.</p>
<pre><code>$("#form-login").submit(function(event) {
event.preventDefault();
var $form = $( this ),
log = $form.find( 'input[name="log"]' ).val(),
pwd = $form.find( 'input[name="pwd"]' ).val(),
rememberme = $form.find( 'input[name="rememberme"]' ).val();
$.post( '/ajax/login.php', { log: log, pwd: pwd, rememberme: rememberme },
function(data) {
$(".form-login-status").html(data);
}
);
});
</code></pre>
|
javascript jquery
|
[3, 5]
|
3,327,907 | 3,327,908 |
suppress : this page is accessing information that is not under its control this poses a security risk?
|
<p>I have asp.net page having lots of ajax controls. I am redirect to https:// login page from this asp.net page after session time out. But the page always showing below popup message window when its redirect. </p>
<pre><code> "this page is accessing information that is not under its control
this poses a security risk"
</code></pre>
<p>How can suppress this message window using javascript or jQuery or asp.net code? </p>
|
c# javascript jquery asp.net
|
[0, 3, 5, 9]
|
2,014,388 | 2,014,389 |
Getting source control id in JavaScript function
|
<p>I have taken three textboxes over aspx page. A JavaScript function is associated with these textboxes as:</p>
<pre><code>TextBox1.Attributes.Add("onkeypress","MyFunction()");
TextBox2.Attributes.Add("onkeypress","MyFunction()");
TextBox3.Attributes.Add("onkeypress","MyFunction()");
</code></pre>
<p>The <code>MyFunction()</code> is defined within a JavaScript file.</p>
<p>What I want is to get the control id of the textbox on which the function is associated within the JavaScript function itself. That is, the JavaScript function should look like this:</p>
<pre><code>function MyFunction() {
var myControl = ?;
alert("Key press event occured in "+myControl.ID);
}
</code></pre>
<p>I need the value of <code>?</code>. What should I write there so that I could get the control id, i.e. <code>TextBox1</code>, <code>TextBox2</code>, or <code>TextBox3</code> on which the event occurred?</p>
<p>I know that <code><% =TextBox1.ClientID %></code> will provide the id of <code>TextBox1</code> on client. But I think as I am attaching the onkeypress event with the textbox I should get the source control id within JavaScript function itself.</p>
|
asp.net javascript
|
[9, 3]
|
840,801 | 840,802 |
Set the value of an input tag with type="password" using C# and ASP.Net
|
<p>So I have this input tag:</p>
<pre><code><input type="password" id="password" name="password" runat="server" />
</code></pre>
<p>I'm trying to set its value using C# and ASP.Net before the page loads, but I can't get it to work.</p>
|
c# asp.net
|
[0, 9]
|
4,322,856 | 4,322,857 |
Formatted text in textarea
|
<p>If I have a string</p>
<pre><code><b>This Is In Bold Letters</b>
</code></pre>
<p>then how can I include in a <code><textarea></code> so that the string appears in <strong>BOLD</strong> letters, using javascript & PHP?</p>
|
php javascript
|
[2, 3]
|
5,575,845 | 5,575,846 |
Clear all controls in a ASP.NET page with a Master page
|
<p>I have a asp.net page which is inherited from a master page .I want to clear all controls in this page .I tried using the bellow method .This is not working if a master page is there. Otherwise its working fine any ideas?</p>
<pre><code>private void ClearControls()
{
foreach(Control c in Page.Controls)
{
foreach (Control ctrl in c.Controls)
{
if (ctrl is TextBox)
{
((TextBox)ctrl).Text = string.Empty;
}
}
}
}
</code></pre>
|
c# asp.net
|
[0, 9]
|
3,541,045 | 3,541,046 |
android copy StringBuffer
|
<p>I have declared two string buffers like,</p>
<pre><code>private StringBuffer buf = new StringBuffer(1024);
private StringBuffer bufRetro = new StringBuffer(1024);
</code></pre>
<p>on following code, before bufRetro = buf, buf has proper filled value. However, after copy it, both have no content. How to set one stringBuffer from another one? Thank you.</p>
<pre><code>if(this.v_Id){
buf.append(ch, start, length);
if (bufType.equals(bufOld)){
buf = bufRetro.append(buf);
}
myParsedXMLDataSet.setId(buf.toString());
bufOld = bufType;
bufRetro.delete(0, bufRetro.length());
bufRetro = buf;
Log.d("id", buf.toString());
buf.delete(0, buf.length());
</code></pre>
|
java android
|
[1, 4]
|
3,672,098 | 3,672,099 |
PHP mixed with ASP
|
<p>I have a problem, just redone a homepage that was in ASP (ASPX) to a PHP.
The problem is that i have some links out there that gos like this www.example.com/work.aspx?jid=23 .</p>
<p>I need to take controll over the links a redriect them to the main page.</p>
<p>How to do that? I have created a work.aspx file that i have written som text just for test. When i try to change the file content to do a "Response.Redirect" the file dosent seam to update.. Why?</p>
<p>Regards</p>
|
php asp.net
|
[2, 9]
|
4,167,529 | 4,167,530 |
EXE upload prevention
|
<p>I need to implement EXE file upload prevention in my project in the same way as it is implemented in gmail (even if EXE file is within a password protected zip file, gmail is able to detect it). What approach should I follow?</p>
|
c# asp.net
|
[0, 9]
|
793,936 | 793,937 |
Preventing the SearchView from collapsing
|
<p>I have a <code>SearchView</code> in my action-bar. When the user searches, I invoke my <code>AsyncTask</code> to begin fetching the data but after the data is retuned, the <code>SearchView</code>collapses.</p>
<p>Here's my code that creates the search widget:</p>
<pre><code>public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.search, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
if (this.objAdapter == null) {
searchView.setIconified(false);
searchView.requestFocusFromTouch();
}
return true;
}
</code></pre>
<p>I'd to prevent the user from collapsing the <code>SearchView</code>. I'd the search string to be visible at all times.</p>
<p>How can I do this?</p>
|
java android
|
[1, 4]
|
2,548,842 | 2,548,843 |
content appended with jquery is not part of the DOM
|
<p>I have an empty div <code><div id="content"></div></code> to which I add content via jquery append.</p>
<pre><code>$('#content').append('<div class="sub">sub1</div>');
$('#content').append('<div class="sub">sub2</div>');
$('#content').append('<div class="sub">sub3</div>');
</code></pre>
<p>When I click a button I want to run a jquery that reads the content of each sub, but I get nothing, I think because the div elements were added via javascript, so they're not really on the page. </p>
<pre><code>$('.sub').each(function(){
alert($(this).text());
}
</code></pre>
<p>How can I still operate on html added via javascript? </p>
|
javascript jquery
|
[3, 5]
|
3,624,613 | 3,624,614 |
trying to find the amount of half hours in between two times
|
<p>I can't think right now.... i've been trying to figure out how many half hours there are between two variables, which will have the start and end times like so, 1100 and 1430</p>
<p>I started doing the following but realized time doesnt go to 100!</p>
<pre><code>function process_blocks(startTime,endTime){
var blocks = 0;
startTime = +startTime;
endTime = +endTime;
while(startTime < endTime){
startTime = startTime + 30; // add a half hour, which is a block
blocks++;
}
return blocks;
}
</code></pre>
|
javascript jquery
|
[3, 5]
|
3,097,208 | 3,097,209 |
Unable to get the Text box value in Javascript
|
<p>I am using Jquery Tokeninput to select multiple values but when i tried to select the values in text box it's always coming blank I am using below Jquery function to retreive the val.
Please refer to to my previous question on stack <a href="http://stackoverflow.com/questions/11613194/how-to-send-json-data-from-aspx-page">Here</a></p>
<pre><code> var values = $("#txtTest").val();
$("#Button1").click(function() {
alert(values);
return false;
});
</code></pre>
<p>Please find the screen shot or same.</p>
<p><img src="http://i.stack.imgur.com/borYV.jpg" alt="enter image description here"></p>
|
javascript jquery asp.net
|
[3, 5, 9]
|
1,705,813 | 1,705,814 |
form registration popup with hints
|
<p>Do You know any good plugins which are suposed to display hints popups each time user changes form field. For example when user enters password field there should appear popup with information that password should have at least 8 characters. That just an example. Thanks for help.</p>
|
javascript jquery asp.net
|
[3, 5, 9]
|
3,392,223 | 3,392,224 |
How do i deduct a percentage from a number and assign the difference to the innerHTML attribute using Javascript or Jquery?
|
<p>Im customizing a payment gateway solution using php and jquery. Before i pass the data(ie. customer address, tele, amount of purchase, etc.), I want to deduct 2.9% from the purchase/product amount.(which would be my personal service fee) and then pass the remaining balance to the payment gateway for processing. How would i do this using PHP?</p>
<pre><code>var $adjustedamount;
var $mypercentage = 0.029;
function computemypercentage($original_price){
$adjustedamount = ($original_price += ($original_price * $mypercentage));
return $adjustedamount;
}
document.getElementById("trueamount").innerHTML= computemypercentage(29.99);
</code></pre>
|
javascript jquery
|
[3, 5]
|
4,016,159 | 4,016,160 |
Javascript function to get values from C# fields or properties in ASP.Net
|
<p>I’m new to JavaScript. Basically I want a function in JavaScript which will show me an email preview in a web browser. I’ve stored email’s template, body and contents.</p>
<p><strong>SQL:</strong> </p>
<pre><code>SELECT Name, template, body, contents FROM Email
WHERE EmailID = 1
</code></pre>
<p><strong>C#:</strong>
I have a LinkButton (ID="lnkViewDoc") on asp.net page and the code behind is:</p>
<pre><code>lnkViewDoc.Attributes.Add("onclick", "return preview_email();");
</code></pre>
<p><strong>JavaScript:</strong>
I need a function please which will pick values from the class fields and show it in a web browser. thanks</p>
<pre><code>function preview_email() {
..................
window.open() //Something
}
</code></pre>
<p><strong>Contents:</strong></p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<center>
..................
</center>
</body>
</code></pre>
<p><strong>Body:</strong></p>
<pre><code><div style="text-align: left"> Dear .......,
...........................................
</div>
<div style="text-align: left"> &nbsp;</div>
</code></pre>
|
c# javascript asp.net
|
[0, 3, 9]
|
5,957,708 | 5,957,709 |
Jquery -Validation, Moving to diffrent parts of div
|
<p>I've three div tags in a page.</p>
<pre><code><div id = '1'>
</div>
<div id = '2'>
</div>
<div id = '3'>
</div>
</code></pre>
<p>When a user click on tag, respective div will load,they all will be on one page with one submit button.</p>
<p>Now ,how to validate the div,i've to know which div the user clicked.</p>
<p><strong>update</strong></p>
<p>This is my vaidation script</p>
<pre><code> function x()
{
var x = true;
some validation script
return x;
}
</code></pre>
<p></p>
<p>Shed some light here,it will help me to go forward.</p>
<p>Thanks in advance!!</p>
|
javascript jquery
|
[3, 5]
|
1,541,446 | 1,541,447 |
onclick go to url THEN do something specific
|
<p>i have a page on my site (let's call it list_page.html) with js functions that allow you to click a link and see a list of multimedia objects. clicking another link (on the same page) will hide the div with the multimedia list and reveal a list of video objects. another link will hide whatever list is visible and reveal a list of audio objects, and so on...</p>
<pre><code>$("#multibtn").click(function(){
$(".menuslab").hide();
$(".menuslab > *").hide();
$("#multi_div").fadeIn("slow");
$("#multi_div > *").fadeIn("slow");
});
</code></pre>
<p>if on my main page (mainpage.html) i have a link named "multimedia", is there a way i can get it to navigate to list_page.html AND execute the function that calls the list of multimedia objects?</p>
|
javascript jquery
|
[3, 5]
|
4,328,467 | 4,328,468 |
Match a String in a Webpage along with HTML tags
|
<p>With below code, I am trying to match a text in a web page to get rid of html tags in a page. </p>
<pre><code> var body = $(body);
var str = "Search me in a Web page";
body.find('*').filter(function()
{
$(this).text().indexOf(str) > -1;
}).addClass('FoundIn');
$('.FoundIn').text() = $('.FoundIn').text().replace(str,"<span class='redT'>"+str+"</span>");
</code></pre>
<p>But it does not seems to work.. Please have a look at this and let me know where the problem is...<br>
<a href="http://jsfiddle.net/m4vXx/" rel="nofollow">here</a> is the fiddle
I have tried the below code instead.. </p>
<pre><code>function searchText()
{
var rep = body.text();
alert(rep);
var temp = "<font style='color:blue; background-color:yellow;'>";
temp = temp + str;
temp = temp + "</font>";
var rep1 = rep.replace(str,temp);
body.html(rep1);
}
</code></pre>
<p>But that is totally removing html tags from body...</p>
|
javascript jquery
|
[3, 5]
|
2,156,572 | 2,156,573 |
remove element in jquery then append a new element?
|
<p>I am trying to remove an span element from HTML then replace that element with a new span element.</p>
<p>View the fiddle for a working example: <a href="http://jsfiddle.net/DCJ9X/" rel="nofollow">http://jsfiddle.net/DCJ9X/</a></p>
<pre><code><div id="foo">
<span>FadeOut</span>
</div>
<input id="go" type="button" value="lets go!" />
$('#go').click(function() {
$('#foo span').fadeOut(500, function() {
$(this).remove().parent().append('<span>FadeIn</span>').fadeIn(500);
});
});
</code></pre>
<p>As always I am grateful for your help stack!</p>
|
javascript jquery
|
[3, 5]
|
882,944 | 882,945 |
Pagination with Hibernate Criteria
|
<p>I am facing problem in pagination. I am using criteria. Display length is 10. While clicking pagination it shows different results like list is 9 and 8 like that. How to avoid this kind of pagination problems. I need list 10 every time. How to control this kind of inconsistancy. </p>
|
java javascript
|
[1, 3]
|
2,756,678 | 2,756,679 |
Date compareTo() method always returning -1
|
<p>I've got two Dates and I want to compare them. I've logged the actual date to make sure its correct and it is. </p>
<pre><code>Date photoDate = new Date(mPhotoObject.calendar.getTimeInMillis());
SimpleDateFormat dateFormat = new SimpleDateFormat("M.d.yy");
Log.v("photo date is", dateFormat.format(photoDate));
Date currentDate = new Date(Calendar.getInstance().getTimeInMillis());
Log.v("current date is", dateFormat.format(currentDate));
Log.v("date comparison", photoDate.compareTo(currentDate)+"");
if(photoDate.compareTo(currentDate)<0) {
view.showFooButton(false);
} else {
view.showFooButton(true);
}
</code></pre>
<p>For some reason the compareTo method is always returning -1 even if this date is <strong>not</strong> before the Date argument.</p>
|
java android
|
[1, 4]
|
5,184,008 | 5,184,009 |
jQuery get lasted clicked on element...?
|
<p>Hey, hope someone can help with this..</p>
<p><strong>How can I get the previous ID of a clicked div element using jQuery?</strong></p>
<p>Is this even possible? </p>
<p>e.g. I have two div's named <em>div1</em> and <em>div2</em>, I click on <em>div1</em> then on <em>div2</em>, how can I get the ID of div1?</p>
<p>Many thanks</p>
|
javascript jquery
|
[3, 5]
|
1,039,845 | 1,039,846 |
Sorting a datatable with datatable.DefaultView.Sort
|
<p>I'm trying to sort a datatable. But it's not working.</p>
<pre><code>arr[0] = "name";
arr[1] = "DESC";
myDataSet.Tables["table1"].DefaultView.Sort = arr[0] + " " + arr[1];
</code></pre>
<p>Here, <code>myDataSet</code> refers to dataset I'm using for the reportviewer.</p>
<p>Am I missing something? Is there any other way?</p>
|
c# asp.net
|
[0, 9]
|
563,173 | 563,174 |
jQuery: Inserting formatted text into a textarea
|
<p>I have a drop-down list which causes a text-area to populate with different text depending on what's selected. I have this part working fine, but I'm not able to format the text to show paragraphs. using regular html, just causes it to be printed out.</p>
<p>Does any one know can I create paragraphs, etc?</p>
<p>Thanks Guys!!</p>
|
javascript jquery
|
[3, 5]
|
1,015,380 | 1,015,381 |
jQuery : Animate Widths of Adjacent Floating Divs
|
<p>I'm playing around with a little jquery animation and trying to achieve a very specific effect.</p>
<p>If anyone remembers the old Xbox menus with the panes or 'blades' as they called them, I'm going for something like that using a series of left floating divs. When the page loads, one pane is active and has a large width, displays some information etc. while the other panes are condensed into a very small width. When a smaller pane is clicked on the active pane shrinks to a narrow width, and the clicked expands to display content.</p>
<p>Essentially the HTML looks like this:</p>
<pre><code> <div class="pane active">
</div>
<div class="pane">
</div>
<div class="pane">
</div>
</code></pre>
<p>I'm currently using javascript (jquery) to define all the widths based on the window size so that the panes fill up the whole screen.</p>
<p>Here is the basic jquery event that handles the shrinking and expanding.</p>
<pre><code> // $active is the current wide pane
// $(this) is the clicked pane
// activeWidth is a predefined constant
$active.animate( { 'width' : '100px' }, 200 );
$(this).animate( { 'width' : activeWidth }, 200);
</code></pre>
<p>The only problem I am having is <em>occasionally</em> during this animation, the shrink/grow appear to start at different times (I'm not sure) and create an unpleasant empty space to the far right of the page.</p>
<p>Is there a way to ensure that these two actions happen consistantly in sync? I considered replicating this using absolute positioning.</p>
<p>I'm at work so I can't upload a diagram, but I will try to later if it's too confusing.</p>
|
javascript jquery
|
[3, 5]
|
5,542,284 | 5,542,285 |
Show a set number of <li>s and then hide them to reveal another set number of <li>s
|
<p>I am trying to create a carousel, using floated list items.</p>
<p>When <em>Next</em> is pressed the current 4 visible <code>li</code>s are hidden and the next 4 shown for as many times as needed. Though, there may not always be another 4 to show, as in the case below there would only be 2 more to display.</p>
<p>When <em>Prev</em> is pressed the current 4 visible <code>li</code>s are hidden and the previous 4 shown.</p>
<p>It doesn't need to loop i.e. if <em>Next</em> is pressed enough times it will reach the end, it wont just start back from the beginning again.</p>
<p><a href="http://jsfiddle.net/tw16/5NB6G/" rel="nofollow">http://jsfiddle.net/tw16/5NB6G/</a></p>
<p><strong>HTML:</strong></p>
<pre><code><div id="left">Prev</div>
<ul>
<li>Test 1</li>
<li>Test 2</li>
<li>Test 3</li>
<li>Test 4</li>
<li>Test 5</li>
<li>Test 6</li>
</ul>
<div id="right">Next</div>
</code></pre>
<p><strong>jQuery/JavaScript:</strong></p>
<pre><code>var listLength = $('ul li').length;
var listCounter = 0;
$("#right").click(function() {
if (listCounter == listLength - 1) {
$("ul li").show(400);
listCounter = 0;
}
else {
$('ul li').eq(listCounter).hide(400);
listCounter++;
}
});
</code></pre>
<p>Unfortunately, I haven't been able to adapt the code to the requirements above.</p>
|
javascript jquery
|
[3, 5]
|
3,735,144 | 3,735,145 |
"scroll" to the end of the input after js modifies input's value
|
<p>I have a <code><input id="inp" type="text"></code> that user writes in, and sometimes uses suggests from a dictionary. When a suggest is selected I do: </p>
<pre><code>var input = $('#inp');
input.val(input.val()+suggestedText+' ');
input.focus(); // that is because the suggest can be selected with mouse
</code></pre>
<p>everything works great, but when after adding a suggest that makes the resulting <code>input.val()</code> too long to fit in the edit field, the cursor is at the end of the string (which is good), but only the beginning of the string is visible in the edit field, so the cursor is hidden as well. </p>
<p>As soon as a key is pressed (a key that changes the value) the "scroll" goes to the end of the string hiding the beginning... How to trigger this behavior automatically, without having to press a key?</p>
<p>I have found a solution <a href="http://stackoverflow.com/questions/1962168/scroll-to-the-very-right-of-a-long-text-input">here</a> - but it is not good as the whole input experience is changed... </p>
|
javascript jquery
|
[3, 5]
|
4,575,725 | 4,575,726 |
Using Jquery or Javascript to find unlabled html
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1520981/remove-elements-with-only-a-nbsp-space-using-jquery">Remove elements with only a &nbsp; space using jQuery</a> </p>
</blockquote>
<p>I have an automatically generated HTML feed that is filled with garbage... I am trying to clean it up a bit and would like to use jquery to strip out some of the bad code. So for example on an average page buried in the code there are close to 200x:</p>
<pre><code><div align="center"> </div>
</code></pre>
<p>If there was some sort of id or class element, these would be easy to get rid of. But I can't think of a way to find them without anything actually in them. Can I search by attribute? Or better yet is there a way to find by HTML code...</p>
|
javascript jquery
|
[3, 5]
|
787,034 | 787,035 |
My first jQuery Plugin
|
<p>i recently started learning jQuery and created a plugin for <strong>preventing browser autofill/suggestion</strong>. Could you guys see and let me know if I can do it it any better?</p>
<p>Here's the code</p>
<pre><code>(function($){
var sTime = new Date().getTime();
$(function(){
return $('form').each(function(i, frm){
var inputs = $(frm +':input');
$.each(inputs, function(){
if($(this).attr('type') == 'text')
$(this).attr('name', $(this).attr('name') + "_" + sTime);
});
$(frm).bind('submit', function(){
var inputs = $(frm +':input');
$.each(inputs, function(){
if($(this).attr('type') == 'text')
$(this).attr('name', $(this).attr('name').replace('_'+sTime, ''));
});
})
})
})
})(jQuery);
</code></pre>
|
javascript jquery
|
[3, 5]
|
5,351,841 | 5,351,842 |
How to set the value of dropdown while adding options in Javascript?
|
<p>I use below code to add options for dropdown </p>
<pre><code> //HTML CODE
select(name='folist', id='folist').
//JS Code
for(var i=0;i<data.foNameArray.length;i++){
var combo = document.getElementById("folist");
option = document.createElement("option");
option.text = data.foNameArray[i];
option.value =data.foIdArray[i];
try {
combo.add(option, null); //Standard
}catch(error) {
combo.add(option); // IE only
}
}
</code></pre>
<p>It perfectly works.Now My doubt is how to select the value while adding like selected="selected".</p>
|
javascript jquery
|
[3, 5]
|
1,939,372 | 1,939,373 |
Displaying powers (to the power of 2, 3, 4 etc)?
|
<p>Is it possible to display 2, 3 etc raised as you would when working with maths equations?</p>
|
java android
|
[1, 4]
|
1,231,078 | 1,231,079 |
Passing an ID over an intent
|
<p>I am trying to pass the ID of the clicked on data from my listview to a new activity in a second class i.e. I click the item on the <code>listview</code>.The <code>onListItemClick</code> method is called and starts a new intent. The id is passed with the object in the <code>i.getExtra</code>. Then the id is stored into a new variable on the second class to be used later.</p>
<p>Ive got as far as working out how to pass the id, but I cant seem to work out how I then store it in the new variable on the second class.</p>
<p>Heres my code:</p>
<pre><code>public void onListItemClick(ListView list, View v, int list_posistion, long item_id)
{
long id = item_id;
Intent i = new Intent("com.example.sqliteexample.SQLView");
i.putExtra(null, id);
startActivity(i);
}
</code></pre>
<p>Could anyone tell me how to reference it in the second class? </p>
|
java android
|
[1, 4]
|
5,563,311 | 5,563,312 |
Batch printing files stored on server from website
|
<p>I have an asp.net website which is hosted on AWS.</p>
<p>From this website I need to be able to select multiple PDF files from a list stored on the AWS box and then print them. </p>
<p>Currently my process only allows one PDF to be printed at a time by redirecting them to the PDF filepath within the browser and then the user manually printing from there but this process will become a tedious one should they have many to print.</p>
<p>Anybody have any ideas on how I can achieve this?</p>
|
c# asp.net
|
[0, 9]
|
3,642,690 | 3,642,691 |
Use Content Provider Between Two android application
|
<p>How can i use the content provider between two applications. share the data base. Please share any Example.</p>
|
java android
|
[1, 4]
|
1,132,680 | 1,132,681 |
why it is not alert anything?
|
<p>Here is my <a href="http://cekirgehizmettaksi.com" rel="nofollow">website</a>. When I click the link that id is 'film' It need to alert 'alert something'. But It's not handling? What is the problem?</p>
|
javascript jquery
|
[3, 5]
|
921,576 | 921,577 |
modify jquery datatable automatically instead of on click
|
<p>I have a jquery datatable which allows me to modify cells onclick using this function</p>
<pre><code>$(document).ready(function () {
$('td').click(function () {
var aPos = oTable.fnGetPosition(this);
var aData = oTable.fnGetData(aPos[0]);
var retrievedEntry = aData[aPos[1]];
this.innerHTML = '10';
});
oTable = $('#myHTMLTable').dataTable();
});
</code></pre>
<p>however what i would like to be able to do is to modify the contents of a column based on the entries in the cells of other columns. So if i have "name" and "age" column, if the name == "John" then update age cell data to 10 and if name == "Mike" then update age to say 11;</p>
|
javascript jquery
|
[3, 5]
|
4,681,909 | 4,681,910 |
Periodically Update a TextView in Android Application
|
<p>I am using the MediaPlayer class to play an mp3 file in my application. How do I update a textview control every second with the current position in the mp3 file?</p>
|
java android
|
[1, 4]
|
56,539 | 56,540 |
Do not execute function (click) until previous event is completed
|
<p>Do not execute until previous is completed. If you click quickly, the script is incorrect. If I click several times, the function will be executed without waiting for completion. It becomes messy.</p>
<pre><code>$(".vid1 .next, .vid2 .next").click(function(){
$(".type2").find(".crop").find(".left").find("div:last").clone().insertAfter($(".type1").find(".crop").find(".left").find("div:last"));
$(".type2 .crop .left div:first").animate({marginLeft: '0px'}, 0);
$(".type1").find(".crop").find(".left").find("div:first").clone().insertBefore($(".type2").find(".crop").find(".left").find("div:first"));
$(".type2").find(".crop").find(".left").find("div:first").animate({marginLeft: '0px'}, 0);
$(".type1").find(".crop").find(".left").find("div:first").animate(
{marginLeft: '0px'}, {
duration: 500,
complete: function() {
$(".type1").find(".crop").find(".left").find("div:first").remove();
$(".type1").find(".crop").find(".left").find("div:first").animate({marginLeft: '208px'}, 0);
}
});
$(".type2").find(".crop").find(".left").find("div:first").animate(
{marginLeft: '208px'}, {
duration: 500,
complete: function() {
$(".type2").find(".crop").find(".left").find("div:last").remove();
}
});
});
</code></pre>
|
javascript jquery
|
[3, 5]
|
2,014,150 | 2,014,151 |
jquery bind an event to a class, or something to the same effect?
|
<p>I'd like to bind an event to a class, or any alternative to the redundant code I posted below. Any ideas?</p>
<p>thanks,
mna</p>
<pre>
(function(){
$( "button", "body" ).button();
var submenu=false;
$( "#about" ).click(function() {
$( "#content" ).fadeOut(1000);
$( "#content" ).load('about.html');
$( "#content" ).fadeIn(1000);
});
$( "#community" ).click(function() {
$( "#content" ).fadeOut(1000);
$( "#content" ).load('community.html');
$( "#content" ).fadeIn(1000);
});
$( "#store" ).click(function() {
$( "#content" ).fadeOut(1000);
$( "#content" ).load('store.html');
$( "#content" ).fadeIn(1000);
});
$( "#projects" ).click(function() {
$( "#content" ).fadeOut(1000);
$( "#content" ).load('projects.html');
$( "#content" ).fadeIn(1000);
});
});
</pre>
|
javascript jquery
|
[3, 5]
|
5,860,928 | 5,860,929 |
Javascript / Jquery functions
|
<p>Not sure if I am being totally wrong here but I want to do something like this:</p>
<ol>
<li>Have an external js page (on an external server)</li>
<li>Include the page - OK that is easy etc...</li>
<li>Have a Jquery function on the external page - well actually many functions</li>
<li>Call those functions directly onto the page.</li>
</ol>
<p>All a bit like this:</p>
<p>External js page:</p>
<pre><code>$(document).ready(function() {
function testit() {
$('#test').load('page.php');
}
function testit_1() {
$('#test_1').load('page_1.php');
}
function testit_1() {
$('#test_2').load('page_2.php');
}
});
</code></pre>
<p>Then on the actual page just call:</p>
<pre><code><script type="script/javascript">
testit();
</script>
<div id="test"></div>
</code></pre>
<p>Am I wrong or should that not work?</p>
|
javascript jquery
|
[3, 5]
|
5,513,006 | 5,513,007 |
Showing and hiding <option> with jquery
|
<p>I have three selects (html drop down lists), all contain the exact same values (except the ids of selects are different).</p>
<p>Now I want to do this:</p>
<ul>
<li><p>When a user selects some option in the first select the same option is hidden in the other two. This rule applies to other two selects as well.</p></li>
<li><p>If the option in the second select is changed again then the previously selected option must reappear in the other selects.</p></li>
</ul>
<p>I hope I was clear. I know this should probably be solved with javascript but I don't have enough knowledge of it to write an elegant solution (mine would probably be very long). Can you help me with the this?</p>
|
javascript jquery
|
[3, 5]
|
2,514,018 | 2,514,019 |
Display hidden html code with jQuery
|
<p>There is another solution to display a hidden input when a user choose an option from the <code>select</code> tag?
<strong>I want to put the HTML code outside the JS code.</strong></p>
<p><strong>jQuery code:</strong></p>
<pre><code>$(function() {
var message = new Array(),
$paymentOption = $("#payement_option"),
$messageDisplay = $("#message_display");
message[1] = '<input type="text" name="email" size="30" />';
$paymentOption.change(function() {
var messageIndex = $(this).val();
$messageDisplay.empty();
if (messageIndex > 0)
$messageDisplay.append(message[messageIndex]);
});
});
</code></pre>
<p><strong>HTML code like this:</strong></p>
<pre><code><select name="option"><option value="0">yes</option><option value="1">no</option</select>
</code></pre>
<p><strong>the output:</strong></p>
<pre><code><div id="message_display"></div>
</code></pre>
<p><strong>EDIT:</strong></p>
<p>I want something like:</p>
<pre><code><div id="message_display">
<input type="text" name="email" size="30" />
</div>
</code></pre>
|
javascript jquery
|
[3, 5]
|
5,275,205 | 5,275,206 |
Dropdown output
|
<p>I am using the following code to populate a second dropdown based on a selection made from the first dropdown. First, a project is chosen from the first dropdown, then the second one populates with iterations if a member was assigned to that project. At the moment, the second combobox displays a blank value if the member is not assigned to a project. What I would like to do is populate it with a message if that is the case - something like: -- You are not a member on this project --. Thanks!</p>
<pre><code> protected void fillIterations()
{
selected_project = selectproject.SelectedValue;
SqlConnection conn = new SqlConnection(GetConnectionString());
conn.Open();
cmd3 = new SqlCommand("SELECT DISTINCT(CONVERT(VARCHAR(10), i.StartDate, 103) + ' - ' + CONVERT(VARCHAR(10), i.EndDate, 103)) AS Iteration, i.ProjectIterationID FROM Iterations i, ProjectIterationMember pim WHERE i.ProjectIterationID = pim.ProjectIterationID AND i.ProjectID = '" + selected_project + "' AND pim.MemberID = '" + mem_id + "'", conn);
cmd3.CommandType = CommandType.Text;
SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
DataSet ds3 = new DataSet();
da3.Fill(ds3);
conn.Close();
selectiteration.DataSource = ds3;
selectiteration.DataTextField = "Iteration";
selectiteration.DataValueField = "ProjectIterationID";
selectiteration.DataBind();
//string iteration = selectiteration.SelectedValue;
//check_iteration.Text = iteration;
}
</code></pre>
|
c# asp.net
|
[0, 9]
|
2,781,825 | 2,781,826 |
How do I add an attribute to a link inside a textarea?
|
<p>How do I add an attribute to a link inside a textarea?</p>
<p>Here is my code:</p>
<p><strong>HTML</strong></p>
<pre><code><textarea id="text"><a href="/" id="link">Click here</a></textarea>
<a href="#" id="add_attr">Add attribute</a>
<a href="#" id="remove_attr">Remove attribute</a>
</code></pre>
<p><strong>JavaScript, JQuery</strong></p>
<pre><code>$(document).ready(function()
{
$('#add_attr').click(function()
{
var value = $('#text').val();
//add attribute `class="name"` to the link inside the textarea
return false;
});
$('#remove_attr').click(function()
{
var value = $('#text').val();
//remove attribute `class="name"` from the link inside the textarea
return false;
});
});
</code></pre>
|
javascript jquery
|
[3, 5]
|
4,454,399 | 4,454,400 |
passing a javascript variable as id inside a jquery function
|
<pre><code><li id="sub:777" class="jstree-leaf">
<ins class="jstree-icon2">&nbsp;</ins>
<a class=""><ins class="jstree-icon2">&nbsp;</ins>Story B</a>
</li>
</code></pre>
<p>I need to change the class of the <code><ins></code> tags for a specific <code><li></code>:</p>
<pre><code> var original_sub_id = $j(element).attr('id'); e.g sub:777
var new_sub_id = original_sub_id.split(":");
new_sub_id = new_sub_id.join("\\\\:"); e.g sub\\:777
</code></pre>
<p>I need to pass the <code>new_sub_id</code> variable in the code below, but it does not seem to work:</p>
<pre><code>$j("#"+new_sub_id + "ins:eq(1)").attr("class","jstree-icon2"); // set class to display new icon
</code></pre>
<p>Any suggestion are most welcome.</p>
|
javascript jquery
|
[3, 5]
|
2,760,696 | 2,760,697 |
Countdown with jQuery
|
<p>So, I have this outputted from my DB:
<code>00:01:53</code><br>
Inside a span tag</p>
<pre><code><span class="jb_timer">00:01:53</span>
</code></pre>
<p>So my question is, how can I make it countdown with jQuery?</p>
<p>Thanks.</p>
|
javascript jquery
|
[3, 5]
|
5,232,798 | 5,232,799 |
Retrieve value from web.config system.web section
|
<p>In my .net application <code>web.config</code> file, under the system.web section,</p>
<pre><code><system.web>
<membership configSource="membership.config" />
</system.web>
</code></pre>
<p>and in my membership.config file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<membership defaultProvider="MembershipProvider">
<add applicationName="xxx"
testing="3" />
</providers>
</membership>
</code></pre>
<p>In my application code, how do I get the value for "testing"?</p>
|
c# asp.net
|
[0, 9]
|
3,136,721 | 3,136,722 |
Get base url in dev and production environment
|
<p>I'm using MVC3 and building an a tag (link) using jquery. The problem is I can only get my links to work in either prod or dev, not both. Here is my site's url in production.</p>
<p><a href="http://tvap.mydomain.com" rel="nofollow">http://tvap.mydomain.com</a></p>
<p>This is my development url.
<a href="http://localhost/TVAP" rel="nofollow">http://localhost/TVAP</a></p>
<p>So, I have a link that I'm creating via jquery as follows.</p>
<pre><code> var actionCell = $('#itemlist').find(rowId).find(actionCellId);
$('<a>Edit</a>').attr({ 'id': 'edit-' + response.id, 'href': '/Items/Edit/' + response.id }).appendTo(actionCell);
</code></pre>
<p>In production, this works, and creates a link as</p>
<pre><code> <a id="edit-17" href="/Items/Edit/17">
</code></pre>
<p>But in development (local) it doesn't work as I need this.</p>
<pre><code> <a id="edit-17" href="/TVAP/ItemManagement/Edit/17">
</code></pre>
<p>I get the following from </p>
<pre><code> $(location).attr('host') ==> localhost
$(location).attr('host') ==> http://localhost/TVAP/Items/Index
</code></pre>
<p>Either too little, or too much info. I'd know I can check for localhost and append TVAP as needed, but this seems like a hack. Another developer may use the ASP.NET VS dev server and get a URL will contain localhost but without the TVAP as I'm getting.
i.e. - <a href="http://localhost:64301/Items/Index" rel="nofollow">http://localhost:64301/Items/Index</a></p>
|
javascript jquery
|
[3, 5]
|
5,120,442 | 5,120,443 |
jQuery - how to register a callback for an asynchronous function?
|
<p>I am a jQuery newbie. I have a core js file which will not be visible to my user. I have the following function inside it that makes a server request -</p>
<pre><code>function checkMsgs(t1,t2) {
// poll the url
// return the results
$.get("http://www.mySite.com/web/test.php", {
"t1" : t1,
"t2" : t2
}, function(data) {
return data;
});
}
</code></pre>
<p>Now, I want to call this function, without blocking the thread i.e., asynchronously. How do I make a function call after it returns from this method, but without blocking anything?</p>
|
javascript jquery
|
[3, 5]
|
3,191,471 | 3,191,472 |
how to check in jquery javascript that user upload file is image or not
|
<p>i want to check that user upload file is image or not.</p>
<p>how i can check the type of file is image or not. are any way exist to do this.</p>
|
javascript jquery
|
[3, 5]
|
5,144,658 | 5,144,659 |
How to Fill Up Input boxes from data base based on 1st Entry.?
|
<p>First I'm New to PHP and JavaScript.</p>
<p>I have more then one input boxes for date Entering in PHP.
what I would like to do is if user Enter date in first input box based on this entered date, Rest of the input boxes should fill up automatically from SQL tables (which has date by week) when leave from 1st input box(OnChange).</p>
<p>I don't have any idea about it how can i do that.
Any helps will be appreciate..
Thank you</p>
<p>i have this code for the input boxes </p>
<pre><code>echo '<div class = "start_date" >'; //Start_Date class start
echo '<strong><label for="start_date">Start Date</label></strong>';
echo '<br/><br/>';
for($k=1;$k<=$textboxindex;$k++)
{
echo "<input type=\"text\" class='textboxsize' id= \"inputField$k\" name=\"start_date[]\" value=\"$start_date\" tabindex='$k'/>";
echo "<br/>";
}
echo '</div>'; //Start_date Class End
</code></pre>
|
php javascript
|
[2, 3]
|
576,622 | 576,623 |
Detect close tab/browser without message etc?
|
<p>I would like doing in javascript (jQuery):</p>
<pre><code>if (close tab || close window) {
$.ajax({
type: "POST",
url: "process_form.php",
data: dataString
});
}
</code></pre>
<p>Is this possible without message if you want leave page etc?</p>
|
javascript jquery
|
[3, 5]
|
2,693,651 | 2,693,652 |
Exception class java.util.concurrent.RejectedExecutionException only on galaxy s3
|
<p>I am having problems with my live wallpapers but only on galaxy s3. I get the following error</p>
<pre><code>java.util.concurrent.RejectedExecutionException: Task com.ls.fs.Wallpaper$MyEngine$1@418f2030 rejected from java.util.concurrent.ThreadPoolExecutor@418f1978[Shutting down, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 87]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1967)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:782)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1303)
at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:600)
at com.ls.fs.Wallpaper$MyEngine$1.run(Wallpaper.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
</code></pre>
<p>This is the code around line 266</p>
<pre><code>@Override
public void onCreate(final SurfaceHolder holder){
super.onCreate(holder);
Executor = Executors.newSingleThreadExecutor();
drawCommand = new Runnable(){
public void run(){
glRenderer.onDrawFrame(gl);
egl.eglSwapBuffers(glDisplay, glSurface);
if(isVisible() && egl.eglGetError() != EGL11.EGL_CONTEXT_LOST){
executor.execute(drawCommand);
}
}
};
setTouchEventsEnabled(true);
}
</code></pre>
|
java android
|
[1, 4]
|
3,890,984 | 3,890,985 |
Can I convert an iphone app on android within a specific time?
|
<p>I have made an application which is using simple navigation, IBactions and some animation. I want to also convert it onto android platform but I dont have any idea about it. So i want to ask that can I convert it into 20-25 days or not? B/c I dont have extra time.</p>
|
android iphone
|
[4, 8]
|
3,027,057 | 3,027,058 |
making php response to remain visible when page refresh
|
<p>It is all working fine in my login-script. I get the right responses in my div (id=login_reply) and the session starts. But whenever I refresh the page, the login_reply is gone. How am I able to keep the login_reply? Thank you!</p>
<p>Here is the php: </p>
<pre><code>if (isset($_POST['username'], $_POST['password']))
{
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string(md5($_POST['password']));
$check = mysql_query("SELECT * FROM `userbase` WHERE `user_name` = '$username'");
if (mysql_num_rows($check) > 0)
{
while ($row = mysql_fetch_assoc($check))
{
$user_id = $row['user_id'];
$user_name = $row['user_name'];
$user_email = $row['user_email'];
$user_password = $row['user_password'];
if ($password == $user_password)
{
$_SESSION['user_id'] = $user_id;
if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != '')
echo "Welcome back '$user_name'!";
else
{
echo 'no';
}
}
else
echo 'no';
}
}
else
echo 'no';
}
</code></pre>
<p>Here is the jQuery</p>
<pre><code>$(document).ready(function()
{
$('#login').click(function()
{
var username = $('#username').val();
var password = $('#password').val();
$.ajax(
{
type: 'POST',
url: 'php/login.php',
data: 'username=' +username + '&password=' + password,
success: function(data)
{
if (data != 'no')
{
$('#logform').slideUp(function()
{
$('#login_reply').html(data).css('color', 'white');
});
}
else
$('#login_reply').html('Invalid username or password').css('color', 'red');
}
});
return false;
});
});
</code></pre>
|
php jquery
|
[2, 5]
|
3,144,378 | 3,144,379 |
JQuery ignore disabled radio buttons
|
<p>I have the following code that is called on submit, which checks that each Radio button is checked.</p>
<pre><code>$("input:radio").each(function() {
var val = $('input:radio[id=' + this.id + ']:checked').val();
</code></pre>
<p>How can I modify this so that it excludes disabled values? (i.e. If the checkbox is disabled then ignore it)</p>
<p>Thanks</p>
|
javascript jquery
|
[3, 5]
|
1,434,060 | 1,434,061 |
How to change javascript for loop criteria? Newbie question
|
<p>Javascript newbie here, just trying to tweak this bit of code. It checks for all HTML elements with a title attribute and adds the class 'tooltipParent'.</p>
<p>I'd like it to only add the class to elements with a title attribute AND the class 'tooltip'. I think I need to add something to the <em>for</em> loop to check for this extra class?</p>
<pre><code>// loop through all objects with a title attribute
var titles=$('[title]');
// use an efficient for loop as there may be a lot to cycle through
for(var i=titles.length-1;i>-1;i--){
// titled object must be position:relative
$(titles[i]).addClass('tooltipParent');
}
</code></pre>
<p>Thanks!</p>
|
javascript jquery
|
[3, 5]
|
3,811,480 | 3,811,481 |
Is Id necessary in applying jquery functions?
|
<p>Suppose I have two <code>p</code> tags in the document. I want to call two different effects using <strong>jQuery</strong> when <strong>onMouseOver</strong> event happens. Is it necessary that these two <code>p</code> tags be given Ids. Can't it be achieved without giving Ids to these tags ?</p>
|
javascript jquery
|
[3, 5]
|
2,355,909 | 2,355,910 |
Apparently weird compilation error using org.apache.http.entity.StringEntity. Different behavior in two different projects
|
<p>I copied a code that worked fine in an Eclipse Java project to an Android project, and even though I import the same .jars, I get compilation errors in the Android project.</p>
<p>In the Android project, Eclipse shows the error "<em>The constructor StringEntity(String, String, String) is undefined</em>" in the following line:</p>
<pre><code>StringEntity se = new StringEntity("example data.", "application/json", "UTF-8");
</code></pre>
<p>But in the other Java project, it compiles and runs fine. The <a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/entity/StringEntity.html" rel="nofollow">documentation</a> says that the constructor <code>StringEntity(String string, String mimeType, String charset)</code> does exist.</p>
<p>I'm importing the same <code>org.apache.http.entity.StringEntity</code> in the two projects. The jars used in the Eclipse project are the same used in the Android project. I even copied and pasted them. I cleaned the project too. Still no success. Can anyone please explain to me why this error is happening?</p>
|
java android
|
[1, 4]
|
4,527,973 | 4,527,974 |
How to send an value from .aspx page to JavaScript file?
|
<p>I have these functions:</p>
<pre><code>function clear(txtvalue)
{
}
function EnableValue (txtvalue, rfvValue)
{
}
<asp:Button ID="btn1" runat="server" OnClick="btn1_Click" onclientClick =" return clear('"+txtValue.ClientID+'"); Text="Button" />
<asp:Button ID="btn2" runat="server" OnClick="Button1_Click" onclientClick ="return EnableValue ('"+txtValue.ClientID+'",'"+rfvValue.ClientID+'")"; Text="Button" />
</code></pre>
<p>I have two functions where I am trying to send an value from my .aspx page (button)
to a JavaScript file.</p>
<p>I get an error telling server tag is not well formed.</p>
<p>What is the issue here?</p>
|
asp.net javascript
|
[9, 3]
|
492,961 | 492,962 |
AndroidRuntime error: Parcel: unable to marshal value
|
<p>I am trying to pass a HashMap to a new activity using the intent.puExtra function. Stepping through the debugger it seems that it adds the HashMap no problem, however when startActivty() is called I get a runtime error stating that Parcel: unable to marshal value com.appName.Liquor.</p>
<p>Liquor is a custom class that I created, and I believe it, in combination with a HashMap, is causing the problem. If I pass a string rather than my HashMap it loads the next activity no problem.</p>
<p>Main Activity</p>
<pre><code>lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String cat = ((TextView) view).getText().toString();
Intent i = new Intent(OhioLiquor.this, Category.class);
i.putExtra("com.appName.cat", _liquorBase.GetMap());
startActivity(i);
</code></pre>
<p>Liquor Class</p>
<pre><code>public class Liquor
{
public String name;
public int code;
public String category;
private HashMap<String, Bottle> _bottles;
public Liquor()
{
_bottles = new HashMap<String, Bottle>();
}
public void AddBottle(Bottle aBottle)
{
_bottles.put(aBottle.size, aBottle);
}
}
</code></pre>
<p>Sub Activity</p>
<pre><code>public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
HashMap<Integer, Liquor> map = (HashMap<Integer, Liquor>)getIntent().getSerializableExtra("com.appName.cat");
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, GetNames(map)));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
</code></pre>
<p>When the runtime error exists it never makes it into the sub activity class. So I'm pretty sure the problem exists in the adding of the HashMap to the intent, and based off the error I believe my Liquor class is the cause, but I can't figure out why.</p>
<p>Your help will be much appreciated. Thanks!</p>
|
java android
|
[1, 4]
|
5,647,360 | 5,647,361 |
JQuery/javascript how do I get the ID of an object?
|
<pre><code>function cat() {
this.getMyID = function() { alert(this.id); } ;
}
var bob = new cat();
// I want it to say 'bob'
bob.getMyID();
</code></pre>
<p><a href="http://jsfiddle.net/n7eHj/" rel="nofollow">http://jsfiddle.net/n7eHj/</a></p>
<p>alerts undefined, any ideas?</p>
<p>I'll elaborate, this is what I want to do - insert into an onclick method of a button something that calls another function, eg:</p>
<pre><code>function cat() {
this.render = function() { $('#myButton').attr('onclick', 'this.meow()'); };
}
var bob = new cat();
bob.render();
</code></pre>
<p>However this will fail because 'this.meow' is nonsense. If I knew the ID, ie. bob, then I could change it to do <code>.attr('onclick', theID + '.meow()'); };</code></p>
|
javascript jquery
|
[3, 5]
|
313,576 | 313,577 |
How can I prevent a change event from being fired from a selected radio button?
|
<p>I'm trying to fire a change event for a selected group radio button but this event gets fired if I select an already selected radio button. Can I prevent this from happening? </p>
<pre><code>$("input[type='radio']").mouseup(function(){
...
}).change(function(){
...
});
</code></pre>
<p>HTML</p>
<pre><code><label class="radio">
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
Option one
</label>
<label class="radio">
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
Option two
</label>
</code></pre>
|
javascript jquery
|
[3, 5]
|
790,747 | 790,748 |
onkeyup not working on hide()
|
<p>I'm trying to show and hide div contents depends on the input of the user.</p>
<p>Here are my codes:</p>
<pre><code><input type="text" name="pass" id="pass" onkeyup="check_input(this.value)">
<div id="repeated_pattern" style="display:none">
<b>REPEATED PATTERN</b>
<p>Repeated characters</p>
</div>
<script>
function check_input(value){
//this would check if there are 3 or more characters repeated consecutively
var repeat_pattern = /(.)\1\1/.test(value);
if(repeat_pattern) {
$("#repeated_pattern").show(500);
}else{
$("#repeated_pattern").hide(500);
}
}
</script>
</code></pre>
<p>Tests:</p>
<ol>
<li>When I try to input <code>gg</code>, the div contents did not show so the result is ok</li>
<li>When I try to input <code>ggg</code>, the div contents show so the result is ok</li>
<li>But when I try to remove the one <code>g</code> so it is now <code>gg</code>. It supposed to be the div contents must be hide but still it showing. <code>onkeyup</code> is not working properly with the <code>hide()</code> function. </li>
</ol>
<p>How to onkeyup work with hide() or vice versa?</p>
|
javascript jquery
|
[3, 5]
|
4,329,630 | 4,329,631 |
How to set ckeditor config when using the jquery version?
|
<p>I'm using the jquery version of ckeditor, like this:</p>
<p><code>$(".textarea").ckeditor();</code></p>
<p>I need to specify the toolbar buttons, but I don't know how. All the help I found here on stackoverflow or using google was for the old javascript ckeditor version, OR I don't know how to use it with jquery (code above).</p>
<p>Also, how do I specify the css file location, so that the ckeditor loads my css and displays the data the same way it will be displayed on the site?</p>
<p>Anyone can help with this mess?</p>
|
javascript jquery
|
[3, 5]
|
1,982,148 | 1,982,149 |
jQuery newbie: how can I pass arguments to an event handler function?
|
<p>I'm looking at the example for the "click" event in the jQuery documentation <a href="http://docs.jquery.com/Events/click#fn" rel="nofollow">here</a>. I can refactor the two anonymous functions as follows and it still works:</p>
<pre><code>$(document).ready(function(){
$("p").hover(hilite, remove_hilite);
});
function hilite()
{
$(this).addClass("hilite");
}
function remove_hilite()
{
$(this).removeClass("hilite");
}
</code></pre>
<p>However, what if I want to pass an argument to <code>hilite</code>? My first guess was that I should use an anonymous function like <a href="http://docs.jquery.com/How%5FjQuery%5FWorks#Right" rel="nofollow">this</a>. However, this does not seem to work, even when I'm using it without arguments:</p>
<pre><code>$("p").hover(
function()
{
hilite();
}
,
function()
{
remove_hilite();
}
);
</code></pre>
<p>I also tried refactoring as follows, but this did not work either:</p>
<pre><code>$(document).ready(function(){
$("p").hover(hilite2, remove_hilite);
});
function hilite2(){
return hilite();
}
</code></pre>
<p>What is the proper way to do this? I feel like I have a big conceptual misunderstanding. In particular, I am unclear about how in my first refactoring, the <code>this</code> object is passed to the <code>hilite</code> function.</p>
|
javascript jquery
|
[3, 5]
|
196,685 | 196,686 |
How to use jQuery to FIND & REPLACE given text with a matching URL instead
|
<p>Hey there, in short I'm looking to parse a web page and find the text "class abc" and create a url like this: <a href="http://www.site.com/code/documentation/classes/classabc/index.html" rel="nofollow">http://www.site.com/code/documentation/classes/classabc/index.html</a></p>
<p>I'm basically gonna create links from my hosted svn code website to documentation I've generated via doxygen from the same codebase. </p>
|
javascript jquery
|
[3, 5]
|
5,884,435 | 5,884,436 |
Play Sound Javascript/Jquery
|
<p>I would like to request help from experts here but I would like to explain my requirements first.
I am building an Ajax Based application that will run on our local intranet network.</p>
<ol>
<li>Now upon every return of request from my Ajax, I need to play a sound in my client browser.</li>
<li>I want to put a sound file (mp3/wav) in my web server (Tomcat) directory where the application will download
and play at the client browser. (I dont want to embed this and will just automatically play)</li>
</ol>
<p>But I basically have this limitation.</p>
<ol>
<li>Our target users intranet computers has no access to the outside internet since this is being block by our network team.</li>
<li>Most of the client runs on Windows XP and Flash might not be updated or not being installed.</li>
</ol>
<p>I know a little jquery but I dont know if what I am thinking is possible and what possible plugin can I use that is
basically cross browser. My target browse runs on IE6/IE7/IE8/FF3. Please advise.</p>
|
javascript jquery
|
[3, 5]
|
3,647,073 | 3,647,074 |
Converting JS String to JSON object
|
<p>I am trying to construct a JS on the fly for a remote validator function using the validation plugin. but for some reason, it's not converting the JS as an object and is treating it as a string and embedding double quotes.</p>
<p>Ex: </p>
<p>The PHP code I have is:</p>
<pre><code>$remoteUrl = '/test/checkusername';
$remoteValidatorJs = "{url: '". $remoteUrl . "',
type: 'post',
async:false,
dataType: 'html',
beforeSend: function(){
alert('Validating Form Field');
},
complete: function(){
alert('Completed Validation of Form Field');
},
dataFilter: function(html) {
return html;
}
}";
$validation[ 'rules' ][ 'Name' ][ 'remote' ] = $remoteValidatorJs;
</code></pre>
<p>How do I frame or convert the JS in <code>$remoteValidatorJs</code> variable so, it eventually looks like the content in the following "remote" section, when the array is printed:</p>
<pre><code>$("#testForm").validate( {
"rules":{
"Name":{
"remote":{
url: '/test/checkusername',
type: 'post',
async:false,
dataType: 'html',
beforeSend: function(){
alert('Validating Form Field');
},complete: function(){
alert('Completed Validation of Form Field');
},
dataFilter: function(html) {
return html;
}
}
}
}
} );
</code></pre>
<p>Thanks,</p>
|
php javascript jquery
|
[2, 3, 5]
|
861,720 | 861,721 |
What's a good JQuery library where I can click the button, and a box (DIV) drops down , for options?
|
<p>Just a regular box, not too big not too small.</p>
|
javascript jquery
|
[3, 5]
|
5,244,136 | 5,244,137 |
handle error of javascript
|
<p>Following error is occurring in my web page on browser</p>
<pre><code>script may be busy or not responding
</code></pre>
<p>I want to avoid it from occurring so how can i do it, </p>
<p>please give me a solution about that</p>
|
javascript jquery
|
[3, 5]
|
5,592,700 | 5,592,701 |
Loop through a php page until session reaches a certain value
|
<p>I am currently developing a web based examination. all the question and answers are save on mysql database. I started the system by retrieving and displaying one question together with the answers which is on radio type. i used a session $_SESSION['questionno']=1; to indicate on what question number will be retrieved and displayed. what i want to do next is that whenever the user clicks the next button it will forward informations to result.php and then the said page will add into the session the answer that was retrieved from the previous page at the same time result.php will increment the $_SESSION['questionno']; and then use</p>
<pre><code>echo ("<SCRIPT LANGUAGE='JavaScript'> window.location='/OE/index.php'; </SCRIPT>");
</code></pre>
<p>to go back to the questions page (index.php) but this time question number two will be displayed because of the incrementation that happened in result.php.</p>
<p>after a series of loops and the user reaches the last question a tally page will then appear.</p>
|
php javascript
|
[2, 3]
|
5,911,876 | 5,911,877 |
How to stop textview field from flashing when clicked
|
<p>I'm creating a timer application for my android. It counts down from a specified time (i.e. 8 minutes) to 0.</p>
<p>I have coded it that when the app starts it shows the specified time. When you click on the <code>TextView</code> displaying the time it starts the count down updating the <code>TextView</code> at the <code>onTick()</code> event. When you click on the <code>TextView</code> again it will stop the countdown and save the remaining milliseconds to resume when the <code>TextView</code> is clicked the next time (essentially pausing the clock).</p>
<p>Everything works as expected. However, when the <code>TextView</code> is clicked it disappears until the click is released. If I hold the click down for 3 seconds then the <code>TextView</code> totally disappears while it is being held and reappears as soon as it is released.</p>
<p>How can I stop this behavior to continue to show the value of the <code>TextView</code> the whole time?</p>
<p>EDIT:</p>
<pre><code> tvPeriod.setOnLongClickListener( new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
valPeriod = 1;
tvPeriod.setText( tvPeriodPrefix + "1" );
return true;
}
});
</code></pre>
|
java android
|
[1, 4]
|
2,774,632 | 2,774,633 |
Multiple user controls and javascript
|
<p>I include a JS file in a user control. The host page has multiple instances of the user control. </p>
<p>The JS file has a global variable that is used as a flag for a JS function. I need the scope of this variable be restricted to the user control. Unfortunately, when I have multiple instances of the control, the variable value is overwritten.</p>
<p>What's the recommended approach in a situation like this?</p>
|
asp.net javascript
|
[9, 3]
|
741,365 | 741,366 |
gridview in asp.net VS2008
|
<p>Have a gridview control and i want to display checkboxes for each row. The checkboxes should only appear if Session["DisplayBox"] == true.</p>
<pre><code><asp:GridView ID="gridView" runat="server" AutoGenerateColumns="False" EnableSortingAndPagingCallbacks="True"
AllowPaging="True" DataSourceID="JObjectDataSource" PageSize="5" OnRowCommand="gridView_RowCommand"
DataKeyNames="ID" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Review">
<ItemTemplate>
<asp:CheckBox ID="chkRejectFile" AutoPostBack="true" runat="server" OnCheckedChanged="chkRejectFile_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</code></pre>
<p>I removed some of the columns and kept the one that i am asking the question about. How would I place a conditional code in the aspx page and check for the session value?</p>
<p>Also, if I page, do i have to explicitly handle keeping track of which row was checked and which wasn't?</p>
|
c# asp.net
|
[0, 9]
|
2,737,743 | 2,737,744 |
Off Fails On Live Elements
|
<p>I am attempting to unbind all events attached to elements inside a container using JQuery's off function however it is doing some odd things.</p>
<p>My code is as follows</p>
<pre><code><div id='container'>
<button id='test_btn'>Test</button>
<button id='live_btn_id1'>Action</button>
<button id='live_btn_id2'>Action</button>
</div>
$("#test_btn").on("click", function(){
$("#container").find("*").off();
});
$("#container").on('click', 'button[id^=live_btn]', function(event) {
alert("hello");
});
</code></pre>
<p>The result of this is that the test_btn correctly stops working however the 'Action' buttons continue to work. However if I do the following:</p>
<pre><code>$("#container").off();
</code></pre>
<p>It works as expected but that also removes my stuff I have attached to container. Is there a reason for this odd behaviour?</p>
|
javascript jquery
|
[3, 5]
|
5,473,887 | 5,473,888 |
How do I log out using the ASP.net Login Control?
|
<p>The problem is that I use both Sessions and the log in control to track the details of the user, but when the user exits the website without logging out, the sessions that are created and updated upon his log-in are abandoned, but the log in control still remembers the user. How do I make sure the log-in control doesn't remember the user, or is there another way to solve this? Thanks.</p>
|
c# asp.net
|
[0, 9]
|
5,109,585 | 5,109,586 |
jQuery.ajax - submit all elements in form without manually entering them
|
<p>I would like to use jQuery.ajax to submit a form using POST without having to specify everything manually in the "data: " part.</p>
<p>This is what I don't want: </p>
<pre><code>data: "username=" + document.getElementById("username").value +
"&email=" + document.getElementById("email").value,
</code></pre>
<p>Is there a way to just have it include alla elements with their values from an entire FORM field? This form is generated dynamically so it would save me a lot of time!</p>
|
javascript jquery
|
[3, 5]
|
5,742,823 | 5,742,824 |
How to create web crawler in java?
|
<p>Hi i want to create a web crawler in java in which i want to retrive some data like title, description from the web page and store the datas in database</p>
|
java android
|
[1, 4]
|
484,494 | 484,495 |
Problem with big amount of dom elements
|
<p>I have problem with DOM elements I need to add 2000 blocks. I try to do this by setTimeout, but then events not working with this elements. Anyone what mistake I have made?</p>
<pre><code>function init(){
$('#regions').prepend("<ul></ul>");
setTimeout(function(){
var opt=$('#regions ul');
for(var i=0; i<50; ++i){
for(var j=0; j<50; ++j)
opt.append('<li class=\"field\"></li>');
}
}, 0);
}
</code></pre>
|
javascript jquery
|
[3, 5]
|
2,985,295 | 2,985,296 |
Javascript: Is there a way to send a cash drawer kick code?
|
<p>I'm trying to make a cash drawer kick open. The command that needs to be sent to the drawer, by way of the receipt printer, is "chr(27).chr(112).chr(0).chr(100).chr(250)". Is there a way to send this command through javascript or other web based language. I want the cash drawer to only open only during certain receipt prints.</p>
|
javascript jquery
|
[3, 5]
|
491,448 | 491,449 |
Adding key/value into array where value is a object
|
<p>Adding key/value into array where value is a object</p>
<p>I want to add some text as a key and Object as a value.</p>
<p>Example</p>
<pre><code>$('#clickme').on('click' , function() {
push to array => "some_text" as (value) and $(this) as key
})
</code></pre>
|
javascript jquery
|
[3, 5]
|
5,930,177 | 5,930,178 |
Load a page's control collection via code - ASP.NET C#
|
<p>I am trying to write a method that will dynamically load a given page's control collection so I can iterate through it and create a list of certain types of controls that reside on the page. The idea is that for any page that inherits from a particular page class, I want to compile a list of editable fields with certain attributes. This all happens outside of these pages (on a different page that is allowing users to manage these other pages). </p>
<p>I've tried both of the following scenarios:</p>
<pre><code>BasePage page = (BasePage)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(string.Format("~/Pages/{0}/Manage.aspx", type.ToString()), typeof(BasePage));
IHttpHandler handler = PageParser.GetCompiledPageInstance(string.Format("~/Pages/{0}/Manage.aspx", type.ToString()), Context.Server.MapPath(string.Format("~/Pages/{0}/Manage.aspx", type.ToString())), HttpContext.Current);
BasePage page = handler as BasePage;
</code></pre>
<p>In both situations, the page variable is initiated but the controls collection is blank, presumably because both of these methods are only loading the codebehind and not the markup. How can I dynamically load the page's control collection?</p>
|
c# asp.net
|
[0, 9]
|
964,197 | 964,198 |
redirect a page automatically
|
<p>how to automatically redirect an ASP.NET page to another after 1 minute using c# code.</p>
|
c# asp.net
|
[0, 9]
|
1,174,872 | 1,174,873 |
Best practice storing language variables in asp.net
|
<p>Given a certain asp.net (or any other language for that matter) website where you want the language strings to be stored together instead of hard-coding them within the aspx page. My friend says you need to store them all in the Web.config. I think the web.config is not made for that and doesn't make sense to put it there. If you have a website containing 2000 language strings in three languages, the webconfig would contain 6000 entries. I think it's better to store them in a table in a database but he doesn't believe me, who's right?</p>
|
c# asp.net
|
[0, 9]
|
5,017,354 | 5,017,355 |
jQuery show / hide doesn't work when moving div inside another
|
<p>I've been wracking my brain on this one and can't figure out why jQuery won't show / hide a div when I place it inside a repeater. Here's the div that I'm trying to show / hide:</p>
<pre><code><div id="EmailForMoreInfo">Hey there!</div>
</code></pre>
<p>The jQuery that I use to show / hide it is here:</p>
<pre><code>if (event.srcElement && event.srcElement.hash == "#2") {
$("#EmailForMoreInfo").show();
} else {
$("#EmailForMoreInfo").hide();
}
</code></pre>
<p>The placement of the 'EmailForMoreInfo' is placed inside a repeater:</p>
<pre><code> <div class="panes">
<asp:Repeater ID="rptProductsCategories" runat="server">
<ItemTemplate>
<div id="tabs-<%# DataBinder.Eval(Container.DataItem, "Key") %>">
<div id="EmailForMoreInfo">Hey there!</div>
<br style="clear:both;" />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</code></pre>
<p>The above jQuery does not work when the 'EmailForMoreInfo' is placed inside the repeater. Moving it outside the repeater, everything works. Analyzing the jQuery shows that it finds the element just fine in either case, but only when it is outside the repeater does it actually show / hide correctly. Otherwise, it always shows. Anyone else run into this and have a workaround?</p>
|
jquery asp.net
|
[5, 9]
|
4,399,077 | 4,399,078 |
What's the best way to extract multiple fields from an asp.net form into a C# list or array ready for processing?
|
<p>I need to extract multiple text/dropdown list fields from an asp.net form and format appropriately ready for sending to recipient via email.</p>
<p>What's the best way of reading those fields without having to hard code each item such as: </p>
<pre><code>item1 = InputField1.Text;
item2 = InputField2.Text;
</code></pre>
<p>I will have about 10 or 20 items on the same input form.</p>
|
c# asp.net
|
[0, 9]
|
3,811,126 | 3,811,127 |
listbox keypress event in server side web form
|
<p>I have a list box (GroupListBox) and I want to catch the enter key press event on this list box in a C# web form. I have tried many methods but no one is working for me.</p>
|
c# asp.net
|
[0, 9]
|
4,272,293 | 4,272,294 |
Solid background for android dialog
|
<p>In android 1.6, the background color is solid but in 2.3 or later, the dialog is transparent, more like opacity 80%. So I created new style</p>
<pre><code><style name="SolidDialog" parent="android:Theme.Dialog">
</style>
</code></pre>
<p>but what should I put inside ??</p>
|
java android
|
[1, 4]
|
3,356,741 | 3,356,742 |
using JQuery to convert html tr tags to uppercase for string comparison
|
<p>I have the following JS function:</p>
<pre><code>function tblFilter(colToFilter) {
var tableToFilter = $("#notesGrid").find("tr");
var columnToFilter = colToFilter;
$.each(columnToFilter, function (i) {
tableToFilter = tableToFilter.filter(":contains'" + columnToFilter + "')");
});
tableToFilter.show();
};
</code></pre>
<p>colToFilter is uppercase and I want to convert what I am comparing to to uppercase as well to ensure case insensitivity.</p>
<p>I have tried this:</p>
<pre><code>function tblFilter(colToFilter) {
var tableToFilter = $("#notesGrid").find("tr");
var columnToFilter = colToFilter;
$.each(columnToFilter, function (i) {
tableToFilter = tableToFilter[i].innerHTML.toUpperCase().filter(":contains'" + columnToFilter + "')");
});
tableToFilter.show();
};
</code></pre>
<p>However it fails saying:</p>
<blockquote>
<p>Microsoft JScript runtime error:
Object doesn't support this property
or method</p>
</blockquote>
|
javascript jquery
|
[3, 5]
|
631,889 | 631,890 |
Creating a jQuery plugin to cause individual elements to react when the window is resized. How do I handle the listeners?
|
<p>I'm working on a plugin that causes something to happen in selected elements when the window is resized. The logic on what happens is perfectly fine, but I'm running into a conundrum when it comes to where to hook on the event listeners.</p>
<p>Basically, the code looks something like this:</p>
<pre><code>$.fn.beAwesome = function() {
return this.each(function(){
// ???
});
}
</code></pre>
<p>While I've completed the rest of the plugin (and have it working just fine on, say, a click even on <code>this</code>), I can't put it "all together" without solving this central issue.</p>
<p>I considered just adding an extra bind <code>resize</code> to <code>$(window)</code> for each awesome element, but there'd be no way to access the element from within the closure:</p>
<pre><code>$.fn.beAwesome = function() {
$window = $(window);
return this.each(function(){
$window.resize(function(){
// can't access initial awesome element
});
});
}
</code></pre>
<p>The other solution that sprung to mind was to instantiate a global data store (probably in <code>$(document).data('beAwesome')</code> or something like that. This, however, doesn't seem Javascript-like, blocking off access once the function runs its course, so I'd have to come up with some roundabout ways to do things like removing the hook. I've definitely seen approaches like these in Javascript libraries I've used in the past, but I don't know whether that's due to necessity or laziness on the authors' parts.</p>
<p>So is there an effective way to accomplish what I'm looking for?</p>
|
javascript jquery
|
[3, 5]
|
770,469 | 770,470 |
href javascript function call
|
<p>I am trying to call a function on href but its showing undefined function but the function itself is working when I call it inside album loop. Is there some other way of calling the function after appending the href? I tried using jquery onclick with the id of anchor but that doesn't work either and got no error. Any idea how I should be calling?</p>
<pre><code>function getPhotosByAlbumID(albumID){
FB.api('/'+ albumID + '/photos',{ limit: 5000, fields: 'source' }, function(photos) {
$(photos.data).each(function(index, value){
console.log(value.source);
});
});
}
FB.api('/me/albums',{ limit: 5000, fields: 'id,name,count,cover_photo,link' }, function(me_album) {
$(me_album.data).each(function(index, value){
FB.api('/'+value.id+'/picture',{ limit: 5000 }, function(picture) {
$('#facebook-cover').append('<li id="'+value.id+'"><a href="javascript:getPhotosByAlbumID('+value.id+');" id="album"><img src="'+picture.data.url+'" /></a></li>');
});
});
});
</code></pre>
<p>Error: Uncaught ReferenceError: getPhotosByAlbumID is not defined </p>
<p>All appended like so.. </p>
<pre><code><ul id="facebook-cover">
<li id="4758611198834"><a href="javascript:getPhotosByAlbumID(4758611198834);" id="album"><img src="image-link"></a></li>
</ul>
</code></pre>
|
php javascript jquery
|
[2, 3, 5]
|
5,600,742 | 5,600,743 |
Hide frameset partially in jquery
|
<p>I have main.jsp page which has frameset. which has two frames.
say frame 1 which has left navigation menu
& in frame 2 which has content.</p>
<p>I just need to hide frame 1 partially & must have link on same frame so could see that after hide the frame</p>
|
java javascript jquery
|
[1, 3, 5]
|
95,196 | 95,197 |
How to make js "for" loop more efficient?
|
<p>I am wondering how to make the loop below more efficient. On my page it has more iterations than 100, that is why, as you can imagine it is troublesome.</p>
<pre><code> for (var i = 0; i < 1000; i += 1) {
var el = document.createElement('div');
el.appendChild(document.createTextNode('Node ' + (i + 1)));
document.getElementById('nodeHolder').appendChild(el);
}
</code></pre>
<p>Thanx for help in advance.</p>
|
javascript jquery
|
[3, 5]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.