Skip to content

Commit

Permalink
Add update container support for links and buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
swklein committed Apr 15, 2015
1 parent 4af3979 commit 8d3735b
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 1 deletion.
1 change: 1 addition & 0 deletions Frameworks/Ajax/ERJQMobile/Components/ERQMButton.api
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
<binding name="data-position-to"/>
<binding name="queryDictionary"/>
<binding name="target"/>
<binding name="updateContainerID"/>
</wo>
</wodefinitions>
1 change: 1 addition & 0 deletions Frameworks/Ajax/ERJQMobile/Components/ERQMSubmitButton.api
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<binding defaults="Boolean" name="data-prefetch"/>
<binding name="data-transition"/>
<binding name="data-position-to"/>
<binding name="updateContainerID"/>
</wo>
</wodefinitions>
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@
</wo:if>
<wo:if condition = "$hasHref">
<webobject name = "LnkLnk"><wo:WOComponentContent /></webobject>
</wo:if>
<wo:if condition = "$updateContainerID">
<script>
$('body').on( "pagecontainershow", function( event, ui ) {
$('<wo:str value = "$jqJavaScriptElementID" />').click(function(event) {
url = $(this).attr("href");
/*url = url.replace(/\/wo\//, '/ajax/');*/
url = url + '?_jqma=1';
url = url + "&_ju=";
url = url + '<wo:str value = "$updateContainerID" />';
$(".ui-page").addClass('ui-disabled');
$.mobile.loading( "show" );
$('#<wo:str value = "$updateContainerID" />').load(url, function() { $.mobile.loading( "hide" ); $(".ui-page").removeClass('ui-disabled'); $('#<wo:str value = "$updateContainerID" />').trigger('create'); } );
return false;
});
} );
</script>
</wo:if>
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
<wo:if condition = "$updateContainerID">
<div data-role = "none" style = "display:none;"><webobject name = "InvSubBtn" /></div>
</wo:if>
<wo:if condition = "$hasAction"> <webobject name = "BtnAction" /> </wo:if>
<wo:else><webobject name = "BtnDirectAction" /></wo:else>
<wo:else><webobject name = "BtnDirectAction" /></wo:else>
<wo:if condition = "$updateContainerID">
<script>
$('body').on( "pagecontainershow", function( event, ui ) {
$('<wo:str value = "$jqJavaScriptElementID" />').click(function(event) {
url = $('<wo:str value = "$jqJavaScriptElementID" />').closest('form').attr('action');
/*url = url.replace(/\/wo\//, '/ajax/');*/
data = $('<wo:str value = "$jqJavaScriptElementID" />').closest('form').serialize();
url = url + '?_jqma=1&<wo:str value = "$invSubBtnId" />=1&AJAX_SUBMIT_BUTTON_NAME=';
url = url + $('<wo:str value = "$jqInvSubBtnId" />').attr('name');
if (data.length > 0) {
url = url + "&";
url = url + data;
}
url = url + "&_ju=";
url = url + '<wo:str value = "$updateContainerID" />';
$(".ui-page").addClass('ui-disabled');
$.mobile.loading( "show" );
$('#<wo:str value = "$updateContainerID" />').load(url, function() { $.mobile.loading( "hide" ); $(".ui-page").removeClass('ui-disabled'); $('#<wo:str value = "$updateContainerID" />').trigger('create'); } );
return false;
});
} );
</script>
</wo:if>
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ BtnDirectAction : WOSubmitButton {
otherTagString = otherTagString;
id = javaScriptElementID;
}

InvSubBtn : AXSubmitButton {
id = invSubBtnId;
action = ^action;
disabled = true;
value = "1";
data-role = "none";
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ public String javaScriptElementID()
return _elementID;
}

/**
* @return the elementID for jquery usage with leading #
*/
public String jqJavaScriptElementID()
{
return "#" + javaScriptElementID();
}

public boolean hasNonNullBinding(String key)
{
if (hasBinding(key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* isButton <strong>true</strong> | false
* string
* id
* updateContainerID if set, only the content of the update container will be replaced
*
* otherTagString tag string added to the container
* class
Expand Down Expand Up @@ -118,6 +119,11 @@ public String href()
return stringValueForBinding("href");
}

public String updateContainerID()
{
return stringValueForBinding("updateContainerID", null);
}

@Override
public void appendCustomTags(StringBuilder sb, NSMutableArray<String> classes, NSMutableArray<String> styles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* actionClass + directActionName
* value
* id
* updateContainerID if set, only the content of the update container will be replaced
*
* otherTagString tag string added to the container
* class
Expand Down Expand Up @@ -66,6 +67,21 @@ public String dataRelDefault()
return null;
}

public String updateContainerID()
{
return stringValueForBinding("updateContainerID", null);
}

public String invSubBtnId()
{
return "isb_" + javaScriptElementID();
}

public String jqInvSubBtnId()
{
return "#" + invSubBtnId();
}

@Override
public void appendCustomTags(StringBuilder sb, NSMutableArray<String> classes, NSMutableArray<String> styles)
{
Expand Down

0 comments on commit 8d3735b

Please sign in to comment.