vendredi 8 mai 2015

jquery post call not working with slash at end of the url

example url:
Target is not to show .php extension, but content stop working when page/url is open with a slash at the end.
http://ift.tt/1F9Oyt6 - form is working with this url
http://ift.tt/1EnOLSI - form is not working with this url

Folder & files:
|
| /js/custom.js
| /manager/create.php
| /manager/creategetpostdata.php
| /manager/.htaccess

Content on custom.js

$(window).load(function() {
    // get post code data
    $('.contentfinder').on('keyup', function(e){
        var xyz = $(this).closest('.contentRow');
        //alert( "success" );
        $.post("../manager/creategetpostdata.php", xyz.find('.contentfinder').serialize(),  function(response) {
            //alert( "success" );
            xyz.children('.showPostData').html(response);
            xyz.children('.showPostData').show();
        });

    });

});

input form on create.php file:

                    <div class="contentRow">
                        <input type="text" name="inputdata" class="form-control contentfinder" placeholder="" />
                        <div class="showPostData"></div>
                    </div>

content on creategetpostdata.php

<?php echo 'hello, what the hell wrong with you. just show content now!'; ?>

content on .htaccess file

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\?([^=]+)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [R=302,L,NE]

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

any help? thanks in advance.

Section will be overlapped by header when come from another page

I have the following problem. What I want is when the user clicks in the navigation bar on "Contact" it will link to the contact page. This is a single page. When you are on contact and then clicking at the bottom of the page on, for example "Over ons" it should be redirect to the homepage (single page) and stop at that section. This works, but when you come from another page, the current section is overlapped by the header.

The jQuery code will not use the offset of the header, only when you are navigation inside the index.html.

Is there a way to fix the issue, so the section will not be overlapped by the header?

Live example:

http://ift.tt/1KRmFou

Wiki hosted on Pbworks and jQuery?

I added jquery and another script at the bottom of my wiki page. However, if I can get node contents with regular javascript (getElementBy…), it doesn't work with jQuery ($("selector") where it always return null. Any idea why ?

You can see the console log here : http://ift.tt/1KRmFoq

And here is my code :

<script src="http://ift.tt/1yCEpkO"></script>

<script>
$(window).load(function(){
console.log(document.getElementById("wikicontent").innerHTML);
console.log($("#wikicontent").html());
});
</script>

Remove the Vimeo placeholder from Iframe

Are there any tricks to remove the placeholder/poster from an Iframe when embedding a video from Vimeo?

I have tried unwrapping the ".flideo" div to remove it's parent div, which is the ".cover" div which contains the placeholder image as a background image. I also tried to empty the "background-image" value, but that didn't work either.

Here is the generated source code:

<div class="video cover" data-thumb="http://ift.tt/1KRmE3R" style="background-image: url(http://ift.tt/1KRmE3R);">
<div class="flideo cloaked" style="-webkit-transform: scale(1.00023496240602); transform: scale(1.00023496240602);">
        <video x-webkit-airplay="allow" preload="metadata" src="http://ift.tt/1zR83Vk"></video> 
</div>
</div>

Jquery simple accordian

I have simple Jquery accordian, but i have problem of changing header color when tab is opened

Here is my code

HTML

<dl class="accordion-modal">

    <dt><a href=""><header>FIRST</header></a></dt>
            <dd class="active-accordian">FIRST CONTENT</dd>

<dt><a href=""><header>SECOND</header></a></dt>
<dd>SECOND CONTENT</dd>

</dl>

JS

(function($) {

  var allPanels = $('.accordion-modal > dd').hide();
  $('.accordion-modal > .active-accordian').show();

  $('.accordion-modal > dt > a').click(function() {
      $this = $(this);
      $target =  $this.parent().next();

      if(!$target.hasClass('active')){
         allPanels.removeClass('active').slideUp();
         $target.addClass('active').slideDown();
      }

    return false;
  });

})(jQuery);

CSS

header{
    background-color:green;
}

.active{
    background-color:red;
}

.active-header-color{
    background-color:blue;
}

What i need when some content is show to add class to that header? Here is working fiddle http://ift.tt/1zR82QY

how can I get the date picker to start select from at least 8 previous days back from this days date?

I try to make a date picker where you can only choose dates from 8 days left. If we have the date 09 / 05-2015 you can not select (8,7,6,5,4,3,2) but you can choose the 01 / 05-2015 and go down. How can i make that?

$(document).ready(function() {

$(".date-picker").datepicker({       
    todayHighlight: true,   
});

$(".date-picker").datepicker().datepicker("setDate", new Date()); //sets the todays date in the input field
$(".date-picker").on("change", function () {
var id = $(this).attr("id");
var val = $("label[for='" + id + "']").text();
$("#msg").text(val + " changed");
});

}); // end of document ready

Ajax in .NET for form editing

I have a form where user can create a complex object. When click on "Add action", then an Ajax call is made in JS, and I use a partialview as return, then I show it as accordion in the form and all is OK for that creation form.

Now, I want to make the same form but for editing, so I have my basic form that works well, but I'm like blocked for the edit form, especially for the partiaviews called by pressing the "Add action" button ...

In the Edit Form, I have a List that contains all the data of each "add action", How can I handle/load/show this in the view?

Can I make one include of the partialView (and passing data) by only using C#?

here is what I've did:

Finally, this is my ajax call from Create JS:

    var x = 0; // problem count
    // method called when user click on add problem
    $(".add_action_button").click(function (event) {
        event.preventDefault();

        // ajax call to partial with prefix
        var prefix = "actionList[" + x + "]";
        $.ajax({
            url: "@Url.Action("AddAction", "Home")",
            cache: false,
            type: "GET",
            dataType: "html",
            traditional: true,
            data: { prefix: prefix, accordioncounter: x + 1 },
            success: function (result) {
                // lot of stuff
            }
        });
    });

AddAction Controller:

public ActionResult AddAction(string prefix, int accordioncounter)
        {
            ViewBag.Prefix = prefix;
            ViewBag.accordioncounter = accordioncounter;

            return PartialView("_AddAction", new ActionViewModel());
        }

_AddAction View:

@model MyModel.ActionViewModel

@{
    if (!string.IsNullOrEmpty(ViewBag.Prefix))
    {
        ViewData.TemplateInfo.HtmlFieldPrefix = ViewBag.Prefix;
    }
}
...

And I have this object in my model from my Edit view:

public List<ActionViewModel> actionList { get; set; }

Thanks in advance for your help :-)