Making a hyperlink for Angularjs - javascript

I am working on a mobile site. I have created a hyperlink that works and was written in basic javascript.
'Go to Tour info '
This code works fine. But I wanted to change the code too better work with angularjs. I tried rewriting it just as...
'<a ng-href="/tours/'+$scope.tourmarkers[i]._id+'">Go to Tour info </a>'
where i cut off part of the of the url that was already being used. I changed the href by adding the ng in front. But I do not feel this is an angular statement. How can i make my original hyperlink be written for angularjs??

try this:
<a ng-href="{{'/tours/' + $scope.tourmarkers[i]._id}}">Go to Tour info </a>

try this
<a ng-href="/tours/{{$scope.tourmarkers[i]._id}}">Go to Tour info </a>
OR
in your controller
$scope.path = '/tours/' + $scope.tourmarkers[i]._id
now in view
'<a ng-href="{{path}}">Go to Tour info </a>'
since ng-href binds dynamically

Related

Dynamically Add Title to a popover element - jQuery

I'm trying to set a title to my popover object on my local project. I've already included these :
bootstrap.css v4.2.1
jquery.min.js v2.2.0
bootstrap.min.js v4.2.1
popper.min.js v1.11.0
I had a simple button
<i id="Dualstack-Pvt" class="fa fa-info-circle float-right" data-toggle="popover" data-content=""></i>
When I click on that i, I want to set the title + content dynamically
so I did these :
console.log("title = ", response.name); // it is working
$('.fa-info-circle#'+objectName).attr("title", response.name);
$('.fa-info-circle#'+objectName).attr('data-content',JSON.stringify(response));
Result
title seems to be dynamically added to the DOM.
But the popover seems to have a hard time rendering it correctly.
You can change
$('.fa-info-circle#'+objectName).attr("title", response.name);
into
$('.fa-info-circle#'+objectName).attr("data-original-title", response.name);
However, please take a look into the documentation on a proper way of refreshing the contents of the popover.
You could do this
$('.fa-info-circle#'+objectName).attr('data-content',JSON.stringify(response.name));
or
$('.fa-info-circle#'+objectName).attr("title", response[0].name);

Creating Dynamic FTP Link in JqGrid Column

I'm creating a dynamic link on the last "column" of the jqGrid,and I'm putting an a tag inside this column,the value of "href" must be a link which is coming from my action and is an ftp address.
The problem is that despite the correct value of href,clicking the link navigates the user to the wrong url which is starting with "http"!!!
I wanna remove this extra "http"!!!
Here is the code to
'<a id="file" href="//' + rowobject.GeneratedFilePath + '" title="download"><div class="icon-details fa fa-external-link" style="display:inline-block"></div></a><span> </span>';
and here is the generated link <a> in runtime:
<a title="download" href="//ftp.test.com/Stat_On_150125_Daily.csv" id="file"><div style="display:inline-block" class="icon-details fa fa-external-link"></div></a>
and by clicking the link I'll be navigated to the following url:
http://ftp.test.com/Stat_On_150125_Daily.csv
The solution was really easy!!
I've found it,I have to add ftp:// in the beginning of href value
That's it.
<a title="download" href="ftp://ftp.test.com/Stat_On_150125_Daily.csv" id="file"><div style="display:inline-block" class="icon-details fa fa-external-link"></div></a>
Thanks a lot

How can I use document.getElementById(someid).onclick for tag a

I want to automate to click on some link in a website.
since links on webpage are not direct link such as www.example.com/1.html.
it shows following link address for all the links I am interested in clicking
javascript:void(1)
following is the html code for that link I want to click
<a href="javascript:void(1)" onclick="server_playOn(17,2, 'est', this);">
Life OK
</a>
Once you've got a reference to the link you can just use the click method:
referenceToLink.click();

How To, Tweet Button sample code help?

i'm trying to implement a Tweet Button from this page http://dev.twitter.com/pages/tweet_button
and it looks like ti doesn't working very well for me. if my website is www.xxx.com the script should be:
Tweet
the graphics load but the count is 0.
i don't understand what could be wrong.
any ideas?
Thanks
Try this code, using jQuery
<img id="tweetButton" style="cursor:pointer;" title="Share this on Twitter" src="http://a3.twimg.com/a/1294785484/images/goodies/tweetn.png" />
$("#tweetButton").click(function () {
window.open("http://twitter.com/share?url=xxx", "tweet", "status=0,toolbar=0,width=500,height=300");
});
You need to go register for this feature on the twitter developers site. Once you do that it should generate some sort of number or code for you to put on your page that will link everything together and start counting as it should.

inline javascript in href

How can you do something like this:
<a href="some javascript statement that isn't a function call;" >myLink</a>
And have the js in the href execute when the link is clicked.
Just put the JS code directly in there:
fsljk
Though, you should not be doing inline scripting. You should unobtrusively attach event handlers.
<a id="lol" href="/blah">fdsj</a>
<script>
document.getElementById('lol').onclick=function() {
/* code */
};
</script>
<a href="javascript:var hi = 3;" >myLink</a>
Now you can use hi anywhere to get 3.
You can write inline-code in the same way as
<a href="javascript:[code]">
This method is also available in other tags.
addition
if you want to Execution when something tag clicking, you can fix with onClick attribute
<a onClick="function()">
I know this question is old but I had a similar challenge dynamically modifying the href attribute that sends an email when the anchor tag is clicked.
The solution I came up with is this:
$('#mailLink,#loginMailLink,#sbMailLink').click(function () {
this.setAttribute('href', "mailto:" + sessionStorage.administrator_mail_address + "?subject=CACS GNS Portal - Comments or Request For Access&body=Hi");
});
<a id="loginMailLink" href= "#" style="color:blue">CACS GNS Site Admin.</a>
I hope that helps.

Categories

Resources