|
When the anonymous function you've passed to window.setTimeout is called, this will be pointing to the global scope, rather than the specific object instance that called setTimeout . This is one of the confusing quirks of javascript code.
There are several possible solutions in the answers to this SO question[^]. For example:
- Save the outer
this reference:
var me = this;
window.setTimeout(function(){me.on()}, 5000); - For modern browsers, use the built-in
bind function[^]:
window.setTimeout(this.on.bind(this), 5000); - Use jQuery's
proxy method[^]:
window.setTimeout($.proxy(this.on, this), 5000);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
$("#button1").val() + $("#button2").val();
However, what you asked doesn't really make any sense. Button's don't really have values. Perhaps you mean something like a calculator where you have buttons for numbers?
If so, then on each click of a button add to the value in the textbox.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
how to bind data to infragistics webhierarchicaldatagrid through javascript
im having data in datatable i need to bind this dt to webhierarchicaldatagrid
this is the
<ig:webhierarchicaldatagrid id="whdg1" runat="server"
autogeneratecolumns="false" autogeneratebands="false" initialexpanddepth="0" datakeyfields="CenterID"
initialdatabinddepth="0" height="500" width="100%">
<expandcollapseanimation slideopendirection="Auto" slideopenduration="300" slideclosedirection="Auto"
slidecloseduration="300">
<clientevents populated="" populating="">
<columns>
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="Term" key="Term" header-text="Term">
<ig:bounddatafield datafieldname="" key="" header-text="">
<bands>
<ig:band key="" autogeneratecolumns="false" datakeyfields="">
<columns>
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<ig:bounddatafield datafieldname="" key="" header-text="">
<behaviors>
<ig:activation activecolumncssclass="igg_ActiveColumn" activerowcssclass="igg_ActiveRow"
activecellcssclass="igg_ActiveCell" enabled="true">
|
|
|
|
|
Have you asked Infragistics?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I am using dynamic datetimepicker that the user can add to any number. But I am having postback problem. Once I submit it, the return page should have all the submitted values including those added dynamic datetimepicker. Right now when i submit and when the page returns, all other static controls with data are there but no dynamically added datetimepicker controls.
Below is the code I used to add datatimepicker dynamically using javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<link rel="stylesheet" media="all" type="text/css" href="jquery-ui.css" />
<link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
$(function () {
var counter = 1;
jQuery("#<%= btnD1Add.ClientID %>").click(function (event) {
event.preventDefault();
jQuery("<li>").appendTo(".Date1More");
jQuery("<label id='lblD1StartTime" + counter + "'>StartTime:</label><input type='text' id='txtD1StartTime" +counter + "' name='txtStartTime1'/>").timepicker({
hourGrid: 10,
minuteGrid: 10,
timeFormat: 'hh:mm tt'
}).appendTo(".Date1More");
counter++;
});
});
</script>
<asp:Button ID="btnD1Add" runat="server" Text="Add more time slots" />
<li>
<ul class="Date1More">
</ul>
</li>
</html>
Now how to use postback for these controls? I had tried to use following code in code but didn't work. I even tried it using !Ispostback() function under pageLoad but no effect.
protected string[] txtStartTime1;
protected void Page_Load(object sender, EventArgs e)
{
txtStartTime1 = Request.Form.GetValues("txtStartTime1");
}
protected void Page_Init(object sender, EventArgs e)
{
try
{
if (txtStartTime1.Length > 0)
{
TextBox txtStTime1 = new TextBox();
txtStTime1.ID = "txtD1StartTime";
txtStTime1.CssClass = "timepicker";
this.Controls.Add(txtStTime1);
}
}
catch(Exception ex){}
}
Is there any another way to do it?
Please help..
Dhyanga
|
|
|
|
|
To understand this behaviour you need to understand page life-cycle properly. I can't explain the whole stuffs here but would recommend you to read it.
Dhyanga wrote: Is there any another way to do it?
Yes, you can very well avoid postback by using ajax or PageMethods. Just see which is best suited in your scenario.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Thank you very much Anurag. I don't know why I didn't think of using Ajax before I spent lots of time thinking on this.
Dhyanga
modified 5-Dec-14 11:17am.
|
|
|
|
|
You are welcome.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
I hope this is the most appropriate forum...
To people (perhaps) with experience doing things like this - does this even sound possible?
I'm having to do a bit of translation work, and I'm using Google Translate a lot (in Chrome). It would be really handy to be able to have four translation boxes on one page (e.g., English to Spanish at the top, and below that, Spanish to English), with buttons to transfer the text back and forth. That would make it far easier to check the back translation.
Might I be able to do such a thing with a user script? And can anyone point me at the best resources for developing these in Chrome? Cheers!
|
|
|
|
|
I saw a similar thing done believe it or not, in Google 'spreadsheet', so that each of two parties could see their native language being typed and the translation to their colleagues' language in another cell - since the sheet was shared the two parties could see everything
I have no doubt you could use a web form and the Google Translation API and javascript - I don't know what you mean 'in Chrome' - have a look here http://davidwalsh.name/demo/google-language-api.php[^] from this code http://davidwalsh.name/google-translate-api[^] - I just did a quick search 'javascript google translate' to find that - you may want to include 'REST' if you do a search, to use the newer Google Translate REST API
|
|
|
|
|
Thanks, by 'in Chrome' I simply meant that I use Chrome, so I'd want a user script that would work in Chrome. Reading around these are now natively support so I should be good...
|
|
|
|
|
विजिवट स्टुडियो में ग्राइडलाईन का उपयगोग कैसे करते है ।
|
|
|
|
|
I tried with Bing translator and this looks like Hindi language. Therefore I suggest you to bring the topic here[^] where it is most probable you will find someone understanding your lauguage. Either way you could write in English if you feel confident enough and we can try to help you.
|
|
|
|
|
Hi,
Get back to code project after long time....
I am using DataTable.js plugin for showing Grid to my salesforce application.
Every thing works fine except pagesize box and search box.
This works fine in IE and Chrome, but in Mozilla Search box and Page size box are overwriting in Grid, they are supposed to appear above the grid, but coming (overlapping) with Grid,
Please let me know if you have any solution for this.
Thanks,
Hemant
By:
Hemant Thaker
|
|
|
|
|
HTML PAGE:
<form id="detailsform">
<label for="cust_name">Name</label>
<input id="cust_name" type="text"/>
<label for="cust_id">Customer-ID</label>
<input id="cust_id" type="text" />
<label for="cust_phone">Phone Number</label>
<input id="cust_phone" type="number" />
<label for="cust_add">Address</label>
<input id="cust_add" type="text" />
<label for="cust_issue">Issue</label>
<input id="cust_issue" type="text" />
<label for="complaint_date">Date of Complaint</label>
<input id="complaint_date" type="text" />
<!--
<table align="center" width="100%">
<tr>
<td align="left" width="35%"><a href="#historypage" style="text- decoration:none">
<input type="button" value="Show History" data-icon="back" data-iconpos="right" id="History" onClick()="getHistory()"/>
</a></td>
<td align="right" width="35%"><a href="#assessmentpage" style="text-decoration:none">
<input type="button" value="Start Assessment" data-icon="check" data-iconpos="right" id="Assessment"/>
</a></td>
</tr>
</table>
</form>
<div data-role="page" id="historypage" data-theme="f">
<div data-role="content">
<form id="historyForm">
<label for="hist_cname">Customer Name</label>
input id="hist_cname" type="text" />
<label for="hist_cid">CustomerID</label>
<input id="hist_cid" type="text" />
</form>
<div id="emp_tb1" align="center" data-theme="b">Here are the details </div>
</div>
Script page:
function getHistory() {
var cust_id = document.getElementById("cust_id");
var myTable = '';
myTable += '<table id="myTable" cellspacing=0 cellpadding=2 border=1>';
myTable += "<tr><td>S.No.</td><td>Date</td><td>Time</td><td>Complaint(s)</td></tr>";
var url = "http://localhost:8080/POS/rest/WebServices/getHistory/"+cust_id.value;
$.getJSON(url, function(json) {
$.each(json, function(i, v) {
myTable += "<tr><td>" + v.date + "</td><td>"+ v.time + "</td><td>" + v.issue
+ "</td><td>" ;
});
});
what i have to do here is,when i clicked the button the function is called and the corresponding result is stored in mytable variable and the result varailbe has to be displayed in history page. here how to navigate from detailsform to historypage while calling the function???
Can anyone help me out to do this?
Thankyou
|
|
|
|
|
Hi all Smile |
I have a problem to formatted an int to the special format
example :
var exp_int = 5640100;
a need writes the integer to 5 640 100
|
|
|
|
|
|
I seek treatment can be done either on the server side (C) or client side (JavaScript)
|
|
|
|
|
Hi all, I am trying to create a web editor using an Iframe. So basically users can open up a page they want to edit in the Iframe and edit away.
I want to be able to grab the content of any element of a page and then do what I need to with it. I ran into some problems when there are elements embedded in other elements such as a div with children each having no id or class attributes.
I tried to solve this problem by first identifying which element was clicked and give it a temporary id if id did not already have one. Then using the new id get the content (I'm trying to get the text). I tried to implement that idea using the code below but it did not work.
$('#myiframe').load(function () {
$(this).contents().find("body").on('click', function (event) {
var a = event.target.tagName;
var divContent = $("#myiframe").contents().find(a);
$(divContent).click(function (e) {
var ClickedElementID = e.target.id;
if (ClickedElementID == "") {
e.target.attr('id', 'tempID');
var myText = $('#tempID').text();
$('#tempID').removeAttr('id');
}
else {
var myText = $(ClickedElementID.text())
}
});
}
}
Please help me make the code above work as I intended, thanks in advance.
modified 22-Nov-14 19:12pm.
|
|
|
|
|
You already have the element, so you shouldn't need to give it an ID. Try:
$(divContent).click(function (e) {
var myText = $(e.target).text();
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi everyone!
I have java web app. And when user logged in on his profile I need to show his location on google-maps using his GPS coordinates, that I retrieved from JSON file.
I've never used javascript, html and css. Could anyone please suggest how to sort this out
Thanks in advance!
modified 19-Nov-14 2:40am.
|
|
|
|
|
Well, this depends on what exactly you want to do.
-How I have done it often is , send a xml or json object when you send the page back to the client. save that json object in may be a javascript variable or a hidden field. write a small parser to fetch data out of this json data structure and provide it to the built in Google Maps library. The library is open source so you can definitely do what ever customization you want to do over it. Be sure of which Google Map library version you are using. You will find a lot of difference in older and newer versions of google map library.
Check the following two links where I used same Google Map client side library to give two different views:
http://www.lalsgroup.com/store-locator.aspx[^]
Click on the radio buttons on the left to select a brand, once you select a brand you will see stuff happening on the map
On this same website, go on the following link and expand the 'Location Map' panel.
http://www.lalsgroup.com/contact-us/[^]
Google map client side API uses js module pattern, same as jQuery plugin-if you know what I am talking about. You need to pass in a initial configuration object, where you can do different defaults, one of them is to setup up initial location. You actually have to pass in default latitutde and longitude and several other config defaults if you want.
Google for 'storeLocator jQuery store locator plugin', you will find a lot of stuff over it.
Hope thats the answer to your question.
Thanks.
Good day!
|
|
|
|
|
Does anyone know a JavaScript library that includes good functions for parsing URL's into their component parts?
Specifically, I would like to extract a query variable from the first URL and use it to construct a new URL.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|