jQuery Mobile how to dynamically add html to dialog box - dialog

I am looking to open a dialog from a specific page and load dynamic data into the dialog.
On the main page I have a number of different links that when clicked provides more information on that link. All the data I have for that link is included on the main page. Somehow I would like to assign the dialog so that it is populated when the dialog opens.
I've tried something like this so far:
<?php foreach($offers as $offer) : ?>
<?php echo $offer->{'offer_name'}; ?>
<?php endforeach; ?>
Then I have an event catcher to catch the link click and then load the "data-desc" meta into the dialog but this doesn't work.
$('.offer').live('click', function(){
var data = $(this).attr('data-desc');
$("#data-desc").html(data);
$("#dialog-offer").dialog("open");
return false;
});
<div data-role="content" id="dialog-offer">
<p class="data-desc"></p>
</div>
I have been looking for an example on how to do this in jQM. This is such a basic necessity for jQM in general that I am surprised that I cannot find any examples. Could someone point me in the right direction. Thanks for the help.

You have a number of errors in your code:
You have given the id="dialog-offer" to a <div> with data-role="content". You should wrap that div in another div with data-role=page
You don't necessarily need to use $("#dialog-offer").dialog("open");. Just set <a href='#dialog-offer'>
You have the wrong selector for the html() call. The class name of the <p> is what you're using with an id-style selector
I have rewritten the code and posted it here: http://jsfiddle.net/PBb3h/
Not exactly like yours, but it does what you want.

Related

Magento - Change links in header

I just started with magento. I try to replace the header links on the default page. I need to replace the text "My Cart" with the following font-awesome icon.
<i class="fas fa-shopping-cart"></i>
But I have no clue where I can change this, the documentation is complicated and not very beginner friendly.
I figured it out. You have to create your own design and assign it in the backend . Then you have to create the following folder structure if it does not exist yet.
\app\design\frontend\yourDesign\default\template\page\template
Now create a file called links.phtml with the following content:
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
//insert links here
</ul>

Orchard infinite scroll

I am trying to use an "Infinite Ajax Scrolling" Orchard module.
https://gallery.orchardproject.net/List/Modules/Orchard.Module.Orchard.jQuery.Ias
I installed the module through admin interface. I made necessary modifications described on the given link. Also, I had to do an extra modification that is described in the comments.
The infinite scrolling thing is just not functioning. I created about 30 blog posts in order to test it. When I scroll through blog posts through public website, first page og blog posts is loaded and when I scroll to the bottom, nothing happens. Pager is not visible (expected), but no new content is appended to the bottom of the list (not expected).
When I scroll through blog posts using Admin interface and I scroll down sufficiently, Chrome console reports couple of things:
Uncaught Error: Syntax error, unrecognized expression: <!DOCTYPE html>
<html lang="en-US" class="static orchard-blogs">
<head>
<meta charset="utf-8" />
<title>Proba - Manage Infinite Blog</title>
<link href="/OrchardLocal/Modul...<omitted>...l> jquery-1.9.1.js:4421
Sizzle.error jquery-1.9.1.js:4421
tokenize jquery-1.9.1.js:5076
select jquery-1.9.1.js:5460
Sizzle jquery-1.9.1.js:3998
jQuery.fn.extend.find jquery-1.9.1.js:5576
jQuery.fn.jQuery.init jquery-1.9.1.js:196
jQuery jquery-1.9.1.js:62
jQuery.fn.jQuery.init jquery-1.9.1.js:201
jQuery jquery-1.9.1.js:62
(anonymous function) jquery.ias.min.js:210
fire jquery-1.9.1.js:1037
self.fireWith jquery-1.9.1.js:1148
done jquery-1.9.1.js:8074
callback
A moment after:
GET http://localhost:30321/modules/orchard.jquery.ias/styles/images/loader.gif 404 (Not Found) jquery-1.9.1.js:6469
jQuery.extend.buildFragment jquery-1.9.1.js:6469
jQuery.extend.parseHTML jquery-1.9.1.js:531
jQuery.fn.jQuery.init jquery-1.9.1.js:149
jQuery jquery-1.9.1.js:62
get_loader jquery.ias.min.js:266
show_loader jquery.ias.min.js:279
paginate jquery.ias.min.js:167
scroll_handler jquery.ias.min.js:99
jQuery.event.dispatch jquery-1.9.1.js:3074
elemData.handle jquery-1.9.1.js:2750
In the admin interface I checked Blog properties and it seems to be configured fine. All default values are in place for [Container, Item, Pager, NextAnchor], and these values are also present in the html file I'm viewing when reported errors occur.
EDIT (after justrhysism's answer)
After implementing justrhysism's answer, I focused on why infinite scrolling works in the dashboard but not in front-end.
When I opened a list of blog posts in dashboard, I located .pager element.
<ul class="pager">
<li class="first"><span>1</span></li>
<li>2</li>
<li class="last">></li>
</ul>
I opened a list of blogs in front-end, and also located .pager element.
<ul class="pager" shape-id="92" style="display: none;">
<li class="first" shape-id="92"><span shape-id="93">1</span></li>
<li shape-id="92">2</li>
<li shape-id="92">></li>
<li class="last" shape-id="92"></li>
</ul>
Then I inspected javascript in charge for triggering async loading of content.
function paginate(curScrOffset, onCompleteHandler)
{
urlNextPage = $(opts.next).attr("href"); // evaluates to $(".zone-content .pager .last a").attr("href")
...............
}
And found out that the urlNextPage variable always gets set to undefined in front-end view.
Problem
I've come across this before. It's a document parsing error. There is a whitespace character (of some description) at the top of the document which Orchard returns instead of the <! which is expected. Somebody with more knowledge of AJAX and document parsing could better describe this.
Solution
To fix this, find the view Document.cshtml within Orchard's Core (located in src\Orchard.Web\Core\Shapes\Views) and copy it to your Theme's View directory.
In this file, look to Line 10 where <!DOCTYPE html> starts. Above this, remove the line break between the closing brace } and the DOCTYPE declaration.
Before:
}
<!DOCTYPE html>
After:
}<!DOCTYPE html>
This should fix your issue.
The Infinite Ajax Scrolling module for Orchard CMS is on Github
https://github.com/grapto/js.Ias
In response to my last edit where urlNextPage was being set to undefined.
I changed the NextAnchor selector in Blog properties:
From default value of ".zone-content .pager .last a" ----> To ".zone-content .pager a".
Also I went into Orchard.jQuery.Ias module -> Scripts/jquery.ias.min.js
Changed paginate function.
Old:
function paginate(curScrOffset, onCompleteHandler)
{
urlNextPage = $(opts.next).attr("href");
....
New:
function paginate(curScrOffset, onCompleteHandler)
{
if ($(opts.pagination).find(".last span").length)
return; // if span element exists in .last element, that means we are on the last page
urlNextPage = $(opts.next).last().attr("href");
....
It works fine now, both in dashboard and in front-end. This is not a very reliable solution, because I made an assumption that last anchor tag in .pager will always lead to the next page. That assumption is based merely on my observations of module's behavior.

Jquery dialog box issue - replace alert by dialog

I try to have a function to display a box with calling dialog('Hello') for example.
I just want to replace the basic function alert by dialog jquery but I don't succeed.
Please help me
**Steps** :
Create a div with id : dialog. Also set it's class
Set the css property of the class display:none
Align it in center with width and height 25%
Create a function dialog(str) that accepts msg as a parameter
Use jquery to change the class of div dialog and set the css property display:block
In the div that you created place a small ok button and map it's click event to a function that hides the div or set's property : display:none
i got this working once i was using it.
$(function() {
$( "#messagebox" ).dialog();
});
And you need some info to go in that box, with this code.
<div id="messagebox" title="some title">
<p>You type your message here</p>
</div>
you use the id to identify which box, and then the rest gives itself :) good luck.. hope it helps. should be easy.

Drupal 6: extracting input field of a search form out of div

The Drupal documentation about theming search forms says:
* $search['search_theme_form']: Text input area wrapped in a div.
My html page which i want to make a drupal theme uses a special search form so i don't want the form's elements to be wrapped into a div. How can i get the clean search form elements not wrapped into div?
Well the Drupal documentation pretty much says it all: http://drupal.org/node/45295
If you just want to remove the div container overwrite the template search-theme-form.tpl.php or whatever template is responsible for the input search field. You have the instruction on how to overwrite in the link above.
If you want more customization than you'll have to do step #2 from the Drupal tutorial.
So from this:
// #file /modules/search/search-theme-form.tpl.php
<div id="search" class="container-inline">
<?php print $search_form; ?>
</div>
To this:
// #file /sites/all/themes/your-active-theme/search-theme-form.tpl.php
<?php print $search_form; ?>
Don't forget to clear the Drupal's site cache.

Layout based on Page - OrchardCMS

I have encountered an issue when using Orchard that I am sure there should be a fairly simple fix / solution for, but I have yet to find it.
I am trying to establish a specific width content area for my home page (580px), and a larger width for content pages (800px).
Layout.cshtml Snippet:
<div id='content'>
#Zone(Model.Content)
</div>
Style:
#Content
{
[...]
width: 580px;
}
Currently - the Content div wraps all of my content regardless of the page (either Home Page or Content). I am wondering if it is possible to use a different div to wrap the content based on the Page, as shown:
Layout.cshtml Idea:
#if(Model.Page != "Home")
{
<div id='fullcontent'>
#Zone(Model.Content)
</div>
}
else
{
<div id='content'>
#Zone(Model.Content)
</div>
}
I'm unsure if the above suggested method is possible (or I am unsure how to check for the current Page) - but any other suggestions would be appreciated.
You can use the Designer Tools module (built-in all recent Orchard versions) and enable the URL alternates feature. You'll then be able to create a layout-url-homepage.cshtml alternate for your layout.
You can use the Layout Selector Module to assign a custom layout to any content item.
http://gallery.orchardproject.net/List/Modules/Orchard.Module.Orchard.DesignerTools
You could use the Vandelay.Classy module to add custom tags to the page that represents your homepage, although it does add a lot of fields to the Page content editor.

Resources