|
Having just been dipped into the steaming pile of crap based on hadoop/java I found the OPs question too stunning to attempt to answer.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I encounter this issue fairly regularly at work, and I'm interested in learning about how others handle it. Basically, when you have a Web app and you make some changes to a JavaScript file, how do you ensure that the correct script is loaded when users navigate to the updated Web app? We're using ASP.NET MVC, IIS 7.
I've done some digging online and a common solution seems to be appending some sort of identifier to script files in the markup, like this:
<script src="scripts/myscript.js?v=123"></script>
Where 'v' is maybe a version number or something along those lines, updated with each deployment. I came across a StackOverflow post in which someone provided a custom HtmlHelper method to append the file's 'LastWriteTime'. But I was wondering how you all handle this.
Thanks in advance!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
|
Ah, wonderful! Thanks! I'll read over them today or tomorrow.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
I have JSON file locally, with array of objects
[
{
"id" :1,
"movieStill": " <img src='imgsMovie/Transformer 1/StillPhoto/StillPhotoBackground.jpg'/>",
},
{
"id" :2,
"movieStill": " <img src='imgsMovie/Transformer 2/StillPhoto/StillPhotoBackground.jpg'/>",
}
]
Then, i have two html pages, one is index.html and movie.html
in index.html i am passing a GET query to the url
(movies.html?id=1)
And then in movie.html, how to grab the value of id from GET query, and show the content from that object?
Because, when i click on item with id: 1 want to show the img from object 1, with id 1, but now it shows me both imgs.
|
|
|
|
|
How do you read the JSON file and where is the code where you actually render the objects? You will have to iterate over the collection of objects and then find the one you are interested in.
Since you haven't mentioned the framework that you are using (or the vanilla JavaScript), there is very less information for me to help you out. But however, go through this: javascript - Get specific JSON object by id from JSON array in AngularJS - Stack Overflow[^] (it covers AngularJS, you can get the idea of doing this in native JavaScript using binary search algorithm).
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Posted an answer on that thread. Close this thread, as reposting is not allowed. You should wait for a while.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
I'm attempting to create jasmine unit tests to an existing Angular web project. But I'm having real problems getting it to work. I'm not very familiar with JavaScript or Angular (far more comfortable in C#), so it could well be a noob mistake.
This is all in Visual Studio 2015 with Jasmine 2.4.1 and Angluar 1.5.8. I'm using the Chutzpah addin to run the tests.
Jasmine works with noddy tests like 2+2 = 4 , but as soon as I try to test the actual app I run into problems.
I started with something simple, testing one of the filters. But I've found 4 different approaches but they all fail with what looks to be internal issues (i.e. not the actual test).
One test is:
describe('Matterhorn 4', function()
{
describe('SortCodeFilter', function()
{
var createFilter;
beforeEach(angular.mock.module('ngRoute', []));
beforeEach(angular.mock.module('LocalStorageModule', []));
beforeEach(angular.mock.module('angular-loading-bar', []));
beforeEach(angular.mock.module('angularUtils.directives.dirPagination', []));
beforeEach(function()
{
module('MatterhornAuthApp', ['ngRoute', 'LocalStorageModule', 'angular-loading-bar', 'angularUtils.directives.dirPagination']);
inject(function($injector)
{
createFilter = $injector.get('SortCodeFilter');
});
});
it('should return stuff', function()
{
expect(createFilter('12345')).toBe('01-23-45');
});
});
});
I think I understand what this is doing, but it fails with things like
Error: [$injector:modulerr] Failed to instantiate module undefined due to:
[ng:areq] Argument 'fn' is not a function, got undefined
I think its references or dependencies, but I've ran out of files to reference at the top of the test and can't work out how you work out what the dependencies even are!
I suppose I'm used to more help or info being provided by the ide/compiler that helps lead me where to look.
|
|
|
|
|
Found that by commenting out chunks of my Angular app definition, the test then works.
Not sure why, what I assume is an issue with the Angular code, is effecting the operation of the test?
|
|
|
|
|
Anyone can help me I was wondering if it is possible to reload only content page, without reloading menu (which is on the left side of the page).
|
|
|
|
|
Absolutely. Google AJAX to learn how to get started.
And despite what some people seem to think, you can do it with just JavaScript, jQuery is not required (if you're not already using it anyway).
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Here's one place to start:
[^]
For what it's worth to you, I only use normal javaScript - never any frameworks.
Another way to load content without refreshing menu bar: read up on iframe's - put your content in one and refresh the content from your menu. Other ways exist too, (such as via DOM) depending upon where your data source is and what it is your refreshing.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
var tempDiv = "<div class = "someClass"></div>";
divs.push(tempDiv);
is this code valid in javascript?
i'm getting error in chrome console that says unexpected identifier
the error is on first line.
|
|
|
|
|
If that's the precise code you've got, and it hasn't been mangled by the site, then it's not valid Javascript. Nested quotes need to be escaped:
var tempDiv = "<div class=\"someClass\"></div>";
var tempDiv = '<div class="someClass"></div>';
You also need to remove the spaces around the = character for the string to be valid HTML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thanks a lot...
that was helpful
|
|
|
|
|
In a vb.net 2010 web form application, I have the following code:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="attendanceletters_default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MPHead" Runat="Server">
<script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="../scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<%If (False) Then%>
<script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
<% End If%>
<script src="../scripts/site.js" type="text/javascript"></script>
<script src="../scripts/json2.js" type="text/javascript"></script>
function GetStudentLetterTemplate(schoolyear, schoolnum, milestone, studentlink, language, semester) {
alert('schoolyear: ' + schoolyear + 'schoolnum: ' + schoolnum + 'milestone: ' + milestone + 'studentlink: ' + studentlink + 'language: ' + language + 'semester: ' + semester);
if (milestone == '999') {
alert('You have selected student(s) having more than one CAIP entry for the current school year');
return;
}
}
I want to display a javascript alert message in production when an error condition exists. The code listed above works in a development envirnonment, but the code would not deploy to a test app server.
Thus can you show me what I can do to fix the code listed above?
If not, would you show me what I can do in a production environment to have a warning message displayed to a user with the least amount of extra code?
I do not care how the warning message is displayed, I just want a warning message to be displayed.
|
|
|
|
|
So, fun story, your JavaScript should be largely unaffected by test/production environments with a couple of important caveats.
- You might have a hard-coded route in your JS that does not exist in production. This could be a specific URI (ie "http://localhost:8080/site/asset") or a relative URL that is not appropriate in your release build ( ie "../../assets" to escape bin).
- Your web browser whitelists sites for script execution, and your production server is not whitelisted.
It's far more likely that your aspx is not producing the correct response on the server side.
Also, this snippet is hysterical:
<script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="../scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script><br />
<%If (False) Then%>
<script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
<% End If%>
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi All,
I am very new to java script , actually I have one HTML page and I am using it in SAP that page contains buttons like 'Save' Bold' 'Italic' Etc all word formatting options.
Like in this editor above we have B I U , Small and BIG and ETC..
when I open that code in note page I have observers that below code has written to create a button.
var nicSaveOptions = {
buttons : {
'save' : {name : __('Save this content'), type : 'nicEditorSaveButton'}
}
};
var nicEditorSaveButton = nicEditorButton.extend({
init : function() {
if(!this.ne.options.onSave) {
this.margin.setStyle({'display' : 'none'});
}
},
mouseClick : function() {
var onSave = this.ne.options.onSave;
var selectedInstance = this.ne.selectedInstance;
onSave(selectedInstance.getContent(), selectedInstance.elm.id, selectedInstance);
}
});
nicEditors.registerPlugin(nicPlugin,nicSaveOptions);
with the above code Save button is displaying in the tool bar.
Now I want to add another button in the tool bar with different logo EX : To send email
Can you please help me how to add new button and it's event for that button.( the above button having even I copied the same code and paste I got that save option two times )
|
|
|
|
|
It looks like you're using a script control renderer called NicEdit[^], so normal JavaScript conventions will only help so much. There's an example that was first thing that came up on Google for me: javascript - Nicedit.js - cannot add custom button - Stack Overflow[^]
I should also note that as per the site, it is no longer under development.
If you're interested in learning JS this is probably not the bast project for you, as you'll be learning the conventions of a dead script module rather than actual JavaScript. I would suggest using one of the many JS tutorials that you can find by googling "javascript tutorial"
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hey everyone and sorry for my bad English. I give my best.
I want to create a offline chatbot and I want that he answer in multiple for special words. (answer must be random)
Here An Exemple:
Me: Hey
Bot: hey
Me:hey
Bot: hi
Here the js code: (what is wrong?)
var $messages = $('.messages-content'),
d, h, m,
i = 0;
$(window).load(function() {
$messages.mCustomScrollbar();
setTimeout(function() {
fakeMessage();
}, 100);
});
function updateScrollbar() {
$messages.mCustomScrollbar("update").mCustomScrollbar('scrollTo', 'bottom', {
scrollInertia: 10,
timeout: 0
});
}
function setDate(){
d = new Date()
if (m != d.getMinutes()) {
m = d.getMinutes();
$('<div class="timestamp">' + d.getHours() + ':' + m + '</div>').appendTo($('.message:last'));
}
}
function insertMessage() {
msg = $('.message-input').val();
if ($.trim(msg) == '') {
return false;
}
$('<div class="message message-personal">' + msg + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
$('.message-input').val(null);
updateScrollbar();
setTimeout(function() {
fakeMessage(msg);
}, 1000 + (Math.random() * 20) * 100);
}
$('.message-submit').click(function() {
insertMessage();
});
$(window).on('keydown', function(e) {
if (e.which == 13) {
insertMessage();
return false;
}
})
var Fake = {
"Hi": ['Hi', 6000]
"Hi": ['Hey', 6000]
"Hey": ['Hey', 6000]
"Hey": ['Hi', 6000]
}
function fakeMessage(msg) {
if (msg == '') {
return false;
}
var resp = Fake[msg][0];
console.log(msg, resp);
|
|
|
|
|
You haven't specified what the problem is. Are you getting an error? Are you getting unexpected results? Can you provide more details to give us a clue as to why you have posted your question.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
SolidSnake7 wrote: (what is wrong?) Only you can tell us. We cannot run your code so you need to do very basic debugging and find out what IS happening. Then you can explain to us so we can help you.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have created HTML tables as below by hard coded the values:
Name weekhandledticket monthlyhandledticket dailyhandledticket credits
xyz 1 2 1 1
My requirement is I want to achieve this dashboard directly on browser without hard coding the values.it should directly taken from external file like javascript .is it possible to attain this requirement using JavaScript itself? Please give me some idea to drive this requirement?
TO BE MORE PRECISE "TO create a dashboard using HTML table and display the data on runtime with help of javascript ?"
|
|
|
|