jeudi 13 août 2015

@Html.LabelFor with an tag inside it

This should be a fairly simple question, all I want to do is use @Html.LabelFor within a razor view. One of my labels is different, it has an <a> tag in it. the problem is when I use LabelFor, it encodes the html as & lt;. I've tried a lot of different approaches to making this happen but none of them are working. Here's the code.

@Html.LabelFor(model => model.Question, new { @for = "Question" })

what should get outputted:

<label for="question"><a href=\"mailto:support@testdomain.com">support@testdomain.com</a></label> ( formatted as a mailto link, stackoverflow just doesn't show it, whether i use code or not)

what does get outputted:

<label for="question"><a href=\"mailto:support@testdomain.com">support@testdomain.com&lt;/a&gt;</label>

(my < have been replaced with & lt ; without the spaces, thus the code shows on the page instead of rendering as a link)

how can I make it output what it should?

note, model.Question is set to <a href="mailto:support@testdomain.com">support@testdomain.com</a>



via Chebli Mohamed

Should I use CSS scaling to accommodate a browser resize on my website?

I see some websites remain static when the browser is resized and some that scale to fit depending on the window size. My question is what's the best to use and how would I implement both a static style or one that would adapt to a browser window resize.

The only information I could find that made it clear was that using max-width: 100%; height: auto; scales certain objects to adapt to a browser window resize. The thing is, it only works for some things not all. Here is my site, as you can see it's a bit of a mess. I would like it all tidied up properly like this site that I believe is static. However if answers can show me a way to make it scalable as well that would be great. But I assume having it static is easier.

Also if it helps here is a fiddle of a page from my site.



via Chebli Mohamed

Add an "click outside of menu to close" jquary/javascript to a menu drop-up that has .toggle()

I would like to add the function to close the menu if i click outside the menu. And also keep the menu button working to close it too: http://ift.tt/1DNxM2R

$(document).ready(function () { $("li").click(function () { $('li > ul').not($(this).children("ul").toggle()).hide(); }); });

Also can you tell me if this is correct for mobile etc? I hope and think so, because it's using .click, right?

This is referring to this post, that I can't reply to the answer to ask there: How to change drop-down menu to drop-up menu



via Chebli Mohamed

How to Put an Image on HTML and Make it Go Across Page?

Some computers have smaller displays, so, how do I put an image that will resize to go across the whole page? This is for a banner. Also, if it does resize, won't the quality change?



via Chebli Mohamed

ng-show, toggle right element on click [Angularjs]

I wana toggle elements but not all elements i need just one on which is clicked.

for example if I have 3 form elements and 3 buttons if I click on button 1. I just wana toggle 1. form element.

This is my current code:

angular:

$scope.formWhat = false;
$scope.formShow = function(item){
                   $scope.formWhat = !$scope.formWhat;
               };

html:

<div ng-repeat="x in comments">
<a href="#" ng-click="formShow(x)">replay</a>
       <form id="<%x.id%>" ng-show="formWhat">
        blbllblblbl
        </form>
</div>

This code will open all forms, but i need just on which is clicked, any idea?



via Chebli Mohamed

Javascript changes all image title attributes and not just the selected img

I am writing a Chrome Extension which allows people to report child sexual abuse images they find online. As soon as they report the image it should be replaced with another that is part of the extension. This all works well.

We also change the href of the image, the title and the alt. This is where things go wrong. The code is like this:

var imgs = document.getElementsByTagName("img");
  for(var idx = 0; idx < imgs.length; idx ++)
  {
    // request.greeting = an img src url
    if(imgs[idx].src == request.greeting) 
    {      
      var width = imgs[idx].getAttribute("width");
      var height = imgs[idx].height;
      var st = imgs[idx].style;

          imgs[idx].src = imgURL;  // Change the Image and set it's properties                   
          imgs[idx].href = "http:\\7ASecond.Net";
          imgs[idx].alt = "Removed by 7ASecond.Net";
          imgs[idx].title = "Removed by 7ASecond.Net";
          resizeImg(imgs[idx]);
         // imgs[idx].setAttribute("style", "width=" + width + "; height=" + height + ";");
        }
      }
    }

  });

What actually happens is that all images on the page have their title, and alt changed. Can you see the problem? Do you want to join the team to make this most needed extension? :D



via Chebli Mohamed

MEAN stack angular html tag inject not working

im new to angular so im trying something new to get used to it.

I use socket.io to get a list of images [car1...car5] and i want to dynamically inject them to the view.

in my html i have a that looks like this:

<div id="section" ng-bind-html="HTML">
    </div>

and in my core.js angular script i have:

var app = angular.module('test', []);

app.factory('socket', function () {
  var socket = io.connect('http://localhost:8080');
  return socket;
});

app.controller('TodoCtrl', function($scope, socket)
{
    socket.emit('images', {}); //send for a list of images
    socket.on('returnImages', function(data)
    {
        for(var i =1;i<=data.list.length;i++) 
        {
            $scope.HTML = '<img style="left:'+(i*50)+'px;" src="/images/'+data.list[i]+'"/>';
        }
        $scope.$digest();
    });
});

but this throws an error:

Error: [$sce:unsafe] http://ift.tt/1HJTijI etc

im following the docs so im not sure whats wrong and i tried including the angular-sanitize but I cant find the cdn link i keep getting a 404



via Chebli Mohamed